ALMaSS  1.0
The Animal, Landscape and Man Simulation System
Landscape Class Reference

The landscape class containing all environmental and topographical data. More...

#include <landscape.h>

Public Member Functions

void FillVegAreaData ()
 
double GetVegArea (int v)
 
void DumpVegAreaData (int a_day)
 
void SkylarkEvaluation (SkTerritories *a_skt)
 
void RodenticidePredatorsEvaluation (RodenticidePredators_Population_Manager *a_rppm)
 
Population_ManagerSupplyThePopManager ()
 Get the pointer to the current main population manager. More...
 
void SetThePopManager (Population_Manager *a_ptr)
 Set the pointer to the current main population manager. More...
 
int SupplyFarmAnimalCensus (int a_farm_ref, int a_LifeStage)
 
int SupplyVegPhase (int a_poly)
 
void SetPolymapping (int a_index, int a_val)
 
int GetPolymapping (int a_index)
 
 ~Landscape (void)
 
 Landscape (void)
 
void SimulationClosingActions ()
 
void Tick (void)
 
void TurnTheWorld (void)
 
int HowManyPonds ()
 Returns the number of ponds in the landscape. More...
 
int SupplyRandomPondIndex ()
 Returns random pond index. More...
 
int SupplyRandomPondRef ()
 Returns random pond polyref. More...
 
int SupplyPondIndex (int a_pondref)
 Returns the index of a pond based on pondref or -1 if not found. More...
 
void SetMaleNewtPresent (int a_InPondIndex)
 Sets a male as being present in a pond. More...
 
bool SupplyMaleNewtPresent (int a_InPondIndex)
 Determines if a male is present in a pond. More...
 
FarmSupplyFarmPtr (int a_owner)
 
FarmManagerSupplyFarmManagerPtr ()
 
int SupplyLargestPolyNumUsed ()
 
bool SupplyShouldSpray ()
 
double SupplyVegDigestabilityVector (unsigned int a_index)
 
double SupplyVegDigestability (int a_polyref)
 
double SupplyVegDigestability (int a_x, int a_y)
 
double SupplyVegHeightVector (unsigned int a_index)
 
double SupplyVegHeight (int a_polyref)
 
double SupplyVegHeight (int a_x, int a_y)
 
double SupplyVegBiomassVector (unsigned int a_index)
 
double SupplyVegBiomass (int a_polyref)
 
double SupplyVegBiomass (int a_x, int a_y)
 
int SupplyVegDensity (int a_polyref)
 
int SupplyVegDensity (int a_x, int a_y)
 
double SupplyWeedBiomass (int a_polyref)
 
double SupplyWeedBiomass (int a_x, int a_y)
 
PollenNectarQuality SupplyPollen (int a_polyref)
 
PollenNectarQuality SupplyPollen (int a_x, int a_y)
 
double SupplyTotalPollen (int a_polyref)
 
double SupplyTotalPollen (int a_x, int a_y)
 
PollenNectarQuality SupplyNectar (int a_polyref)
 
PollenNectarQuality SupplyNectar (int a_x, int a_y)
 
double SupplyTotalNectar (int a_polyref)
 
double SupplyTotalNectar (int a_x, int a_y)
 
bool SupplySkScrapes (int a_polyref)
 
bool SupplyVegPatchy (int a_polyref)
 
bool SupplyVegPatchy (int a_x, int a_y)
 
double SupplyGreenBiomass (int a_polyref)
 
double SupplyGreenBiomass (int a_x, int a_y)
 
double SupplyDeadBiomass (int a_polyref)
 
double SupplyDeadBiomass (int a_x, int a_y)
 
double SupplyLAGreen (int a_polyref)
 
double SupplyLAGreen (int a_x, int a_y)
 
double SupplyLATotal (int a_x, int a_y)
 
double SupplyVegCover (int a_polyref)
 
double SupplyVegCoverVector (unsigned int a_index)
 
double SupplyVegCover (int a_x, int a_y)
 
TTypesOfVegetation SupplyLastSownVeg (int a_polyref)
 
TTypesOfVegetation SupplyLastSownVeg (int a_x, int a_y)
 
TTypesOfVegetation SupplyLastSownVegVector (unsigned int a_index)
 
double SupplyInsects (int a_polyref)
 
double SupplyInsects (int a_x, int a_y)
 
bool SubtractPondLarvalFood (double a_food, int a_polyrefindex)
 Removes larval food from a pond and returns true if it was possible, otherwise false. More...
 
void CheckForPesticideRecord (LE *a_field, TTypesOfPesticideCategory a_pcide)
 Check if needed and record pesticide application. More...
 
double SupplyRodenticide (int a_x, int a_y)
 Gets total rodenticide for a location. More...
 
bool SupplyPesticideDecay (PlantProtectionProducts a_ppp)
 Returns true if there is any pesticide in the system at all at this point. More...
 
double SupplyPesticide (int a_x, int a_y, PlantProtectionProducts a_ppp)
 Gets total pesticide for a location. More...
 
bool SupplyOverspray (int a_x, int a_y)
 Gets the overspray flag. More...
 
double SupplyPesticideP (int a_x, int a_y, PlantProtectionProducts a_ppp)
 Gets plant pesticide for a location. More...
 
double SupplyPesticideS (int a_x, int a_y, PlantProtectionProducts a_ppp)
 Gets soil pesticide for a location. More...
 
double SupplyPesticide (int a_polyref, PlantProtectionProducts a_ppp)
 Gets total pesticide for the centroid of a polygon. More...
 
double SupplyPesticideP (int a_polyref, PlantProtectionProducts a_ppp)
 Gets plant pesticide for the centroid of a polygon. More...
 
double SupplyPesticideS (int a_polyref, PlantProtectionProducts a_ppp)
 Gets soil pesticide for the centroid of a polygon. More...
 
RodenticidePredators_Population_ManagerSupplyRodenticidePredatoryManager ()
 
TTypesOfPesticide SupplyPesticideType (void)
 
GooseFieldListGetGooseFields (double)
 Gets the list of suitable goose foraging fields today. More...
 
void ResetGrainAndMaize ()
 Resets all grain. More...
 
void CalculateOpenness (bool a_realcalc)
 Causes openness to be calulated and stored for all polygons. More...
 
void WriteOpenness (void)
 Stores openness for all polygons to a standard file. More...
 
void ReadOpenness (void)
 Reads openness values from a standard input file for all polygons. More...
 
int CalulateFieldOpennessCentroid (int a_pref)
 Provides a measure of the shortest distance in 360 degree, e-g- looking NE % SW before tall obstacles are encountered at both ends. Searches from centroid. More...
 
int CalulateFieldOpennessAllCells (int a_pref)
 Provides a measure of the shortest distance in 360 degree, e-g- looking NE % SW before tall obstacles are encountered at both ends. Checks all field 1m2. More...
 
int LineHighTest (int a_cx, int a_cy, double a_offsetx, double a_offsety)
 Provides a measure of the shortest distance in using a vector from a_cx,a_cy unitl tall obstacles are encountered in both +ve & -ve directions. More...
 
int SupplyOpenness (int a_poly)
 Get openness for a polygon. More...
 
int SupplyOpenness (int a_x, int a_y)
 Get openness for a location. More...
 
bool SupplyLEHigh (int a_x, int a_y)
 Tests whether the polygon at a_x,a_y is designated as high. More...
 
polylistSupplyLargeOpenFieldsNearXY (int x, int y, int range, int a_openness)
 Returns a pointer to a list of polygonrefs to large open fields within a range of location x,y. More...
 
int SupplySoilType (int a_x, int a_y)
 Returns the soil type in ALMaSS types reference numbers. More...
 
int SupplySoilTypeR (int a_x, int a_y)
 Returns the soil type in rabbit warren reference numbers. More...
 
APoint SupplyCentroid (int a_polyref)
 
APoint SupplyCentroidIndex (int a_polyrefindex)
 
int SupplyCentroidX (int a_polyref)
 
int SupplyCentroidY (int a_polyref)
 
int SupplyCentroidX (int a_x, int a_y)
 
int SupplyCentroidY (int a_x, int a_y)
 
int SupplyFarmIntensity (int a_x, int a_y)
 
int SupplyFarmIntensity (int a_polyref)
 
int SupplyFarmIntensityI (int a_polyindex)
 
TTypesOfLandscapeElement SupplyElementType (int a_polyref)
 
TTypesOfLandscapeElement SupplyElementType (int a_x, int a_y)
 
TTypesOfLandscapeElement SupplyElementTypeCC (int a_x, int a_y)
 
int SupplyCountryDesig (int a_x, int a_y)
 
int SupplyElementSubType (int a_polyref)
 
int SupplyElementSubType (int a_x, int a_y)
 
TTypesOfVegetation SupplyVegType (int a_x, int a_y)
 
TTypesOfVegetation SupplyVegType (int polyref)
 
TTypesOfVegetation SupplyVegTypeVector (unsigned int a_index)
 
int SupplyGrazingPressureVector (unsigned int a_index)
 
int SupplyGrazingPressure (int a_polyref)
 
int SupplyGrazingPressure (int a_x, int a_y)
 
bool SupplyIsCereal (int a_polyref)
 
bool SupplyIsMatureCereal (int a_polyref)
 
bool SupplyIsGrass (int a_polyref)
 
bool SupplyIsGrass2 (TTypesOfVegetation a_vege_type)
 
bool SupplyIsCereal2 (TTypesOfVegetation a_vege_type)
 
bool SupplyHasTramlines (int a_x, int a_y)
 
bool SupplyHasTramlines (int a_polyref)
 
bool SupplyJustMownVector (unsigned int a_index)
 
bool SupplyJustMown (int a_polyref)
 
int SupplyJustSprayedVector (unsigned int a_index)
 
int SupplyJustSprayed (int a_polyref)
 
int SupplyJustSprayed (int a_x, int a_y)
 
int SupplyTreeAge (int a_Polyref)
 
int SupplyTreeAge (int, int)
 
int SupplyVegAge (int a_Polyref)
 
int SupplyVegAge (int a_x, int a_y)
 
int SupplyNumberOfFarms ()
 
int SupplyFarmOwner (int a_x, int a_y)
 
int SupplyFarmOwner (int a_polyref)
 
int SupplyFarmOwnerIndex (int a_x, int a_y)
 
int SupplyFarmOwnerIndex (int a_polyref)
 
TTypesOfFarm SupplyFarmType (int a_polyref)
 
TTypesOfFarm SupplyFarmType (int a_x, int a_y)
 
TTypesOfOptFarms SupplyOptFarmType (int a_x, int a_y)
 
int SupplyFarmArea (int a_polyref)
 
double SupplyPolygonAreaVector (int a_polyref)
 Returns the area of a polygon using the vector index as a reference. More...
 
double SupplyPolygonArea (int a_polyref)
 
void SetBirdSeedForage (int a_polyref, double a_fooddensity)
 Sets the grain forage resource as seen from a goose standpoint at a polygon. More...
 
void SetBirdMaizeForage (int a_polyref, double a_fooddensity)
 Sets the maize forage resource as seen from a goose standpoint at a polygon. More...
 
double SupplyGooseGrazingForageH (double a_height, GooseSpecies a_goose)
 Returns the leaf forage resource as seen from a goose standpoint at a polygon based on the height only. More...
 
double SupplyGooseGrazingForageH (int a_polygon, GooseSpecies a_goose)
 Returns the leaf forage resource as seen from a goose standpoint at a polygon referenced by number based on height only. More...
 
double GetActualGooseGrazingForage (int a_x, int a_y, GooseSpecies a_goose)
 Returns the leaf forage resource as seen from a goose standpoint at a polygon referenced by x,y location. More...
 
double GetActualGooseGrazingForage (int a_polygon, GooseSpecies a_goose)
 Returns the leaf forage resource as seen from a goose standpoint at a polygon referenced by x,y location The amount of food avaiable as grazing resource based on the vegetation height is species specific. More...
 
double SupplyBirdSeedForage (int a_polyref)
 Returns the grain forage resource. More...
 
double SupplyBirdSeedForage (int a_x, int a_y)
 Returns the grain forage resource as seen from a goose standpoint at an x,y location. More...
 
double SupplyBirdMaizeForage (int a_polyref)
 Returns the maize forage resource. More...
 
bool SupplyInStubble (int a_polyref)
 Returns whether its cereal. More...
 
double SupplyBirdMaizeForage (int a_x, int a_y)
 Returns the maize forage resource as seen from a goose standpoint at an x,y location. More...
 
void RecordGooseNumbers (int a_poly, int a_number)
 This records the number of geese on the polygon the day before. To prevent lots of unnecessary clearing of values two values are saved, the number and simulation day - on reading the simulation day number can be used to modify the return value - see GetGooseNumbers() More...
 
void RecordGooseSpNumbers (int a_poly, int a_number, GooseSpecies a_goose)
 This records the number of geese of each species on the polygon the day before. To prevent lots of unnecessary clearing of values two values are saved, the number and simulation day - on reading the simulation day number can be used to modify the return value - see GetGooseNumbers() More...
 
void RecordGooseNumbersTimed (int a_poly, int a_number)
 This records the number of geese on the polygon the day before at a predefined time. To prevent lots of unnecessary clearing of values two values are saved, the number and simulation day - on reading the simulation day number can be used to modify the return value - see GetGooseNumbers() More...
 
void RecordGooseSpNumbersTimed (int a_poly, int a_number, GooseSpecies a_goose)
 This records the number of geese of each species on the polygon the day before at a predefined time. To prevent lots of unnecessary clearing of values two values are saved, the number and simulation day - on reading the simulation day number can be used to modify the return value - see GetGooseNumbers() More...
 
void RecordGooseRoostDist (int a_polyref, int a_dist, GooseSpecies a_goose)
 Records the distance to the closest roost of goose species. More...
 
void GrazeVegetation (int a_poly, double a_forage)
 Removes grazing forage from a poly per m2. More...
 
void GrazeVegetationTotal (int a_poly, double a_forage)
 Removes grazing forage from a poly and divides this out per m2. More...
 
int GetGooseNumbers (int a_poly)
 This returns the number of geese on the polygon the day before. More...
 
int GetQuarryNumbers (int a_poly)
 This returns the number of geese which are legal quarry on the polygon the day before. More...
 
int GetGooseNumbers (int a_x, int a_y)
 This returns the number of geese on the polygon specifed by a_x, a_y the day before. More...
 
int SupplyLastTreatment (int a_polyref, int *a_index)
 
int SupplyLastTreatment (int a_x, int a_y, int *a_index)
 
double GetHareFoodQuality (int a_polygon)
 
double SupplyGlobalRadiation ()
 
double SupplyGlobalRadiation (long a_date)
 
double SupplyRain (void)
 
double SupplyTemp (void)
 
double SupplyHumidity (void)
 
double SupplyMeanTemp (long a_date, unsigned int a_period)
 
double SupplyWind (void)
 
int SupplyWindDirection (void)
 
double SupplySnowDepth (void)
 
bool SupplySnowcover (void)
 
int SupplyDaylength (void)
 
double SupplyRain (long a_date)
 
double SupplyTemp (long a_date)
 
double SupplyWind (long a_date)
 
double SupplyDayDegrees (int a_polyref)
 
double SupplyRainPeriod (long a_date, int a_period)
 
double SupplyWindPeriod (long a_date, int a_period)
 
double SupplyTempPeriod (long a_date, int a_period)
 
bool SupplySnowcover (long a_date)
 
bool IsFieldType (TTypesOfLandscapeElement a_tole)
 
int SupplyPolyRef (int a_x, int a_y)
 
int SupplyPolyRefIndex (int a_x, int a_y)
 
int SupplyPolyRefCC (int a_x, int a_y)
 
int SupplySimAreaWidth (void)
 
int SupplySimAreaHeight (void)
 
int SupplySimAreaMaxExtent (void)
 
int SupplySimAreaMinExtent (void)
 
int SupplyDaylength (long a_date)
 
int SupplyDayInYear (void)
 
int SupplyHour (void)
 Get the hour of the day. More...
 
int SupplyMinute (void)
 Get the minute of the hour. More...
 
unsigned int SupplyNumberOfPolygons (void)
 
TTypesOfLandscapeElement SupplyElementTypeFromVector (unsigned int a_index)
 
int SupplyPolyRefVector (unsigned int a_index)
 
int SupplyPesticideCell (int a_polyref)
 
int SupplyValidX (int a_polyref)
 
int SupplyValidY (int a_polyref)
 
double SupplyPondPesticide (int a_poly_index)
 Get the pesticide concentration per liter from a pond (must be a pond index on calling) More...
 
void CorrectCoords (int &x, int &y)
 Function to prevent wrap around errors with co-ordinates using x/y pair. More...
 
APoint CorrectCoordsPt (int x, int y)
 Function to prevent wrap around errors with co-ordinates using x/y pair. More...
 
void CorrectCoordsPointNoWrap (APoint &a_pt)
 Function to prevent wrap around errors with co-ordinates using a APoint. More...
 
int CorrectWidth (int x)
 
int CorrectHeight (int y)
 
void SetPolyMaxMinExtents (void)
 
void CalculateCentroids (void)
 
void DumpCentroids (void)
 
void BuildingDesignationCalc ()
 used to calculate whether a building is rural or town - for rodenticide use More...
 
void CentroidSpiralOut (int a_polyref, int &a_x, int &a_y)
 
const char * SupplyVersion (void)
 
void DumpPublicSymbols (const char *a_dumpfile, CfgSecureLevel a_level)
 
void DumpAllSymbolsAndExit (const char *a_dumpfile)
 
bool ReadSymbols (const char *a_cfgfile)
 
void DumpMapInfoByArea (const char *a_filename, bool a_append, bool a_dump_zero_areas, bool a_write_veg_names)
 
void Warn (std::string a_msg1, std::string a_msg2)
 
int * SupplyMagicMapP (int a_x, int a_y)
 
int MagicMapP2PolyRef (int a_magic)
 
int SupplyRoadWidth (int, int)
 
double SupplyTrafficLoad (int a_x, int a_y)
 
double SupplyTrafficLoad (int a_polyref)
 
int SupplyTreeHeight (int, int)
 
int SupplyUnderGrowthWidth (int, int)
 
int SupplyTreeHeight (int)
 
int SupplyUnderGrowthWidth (int)
 
long SupplyGlobalDate (void)
 
int SupplyYear (void)
 
int SupplyYearNumber (void)
 
int SupplyMonth (void)
 
int SupplyDayInMonth (void)
 
double SupplyDaylightProp ()
 
double SupplyNightProp ()
 
void SupplyLEReset (void)
 
int SupplyLENext (void)
 
int SupplyLECount (void)
 
LE_Signal SupplyLESignal (int a_polyref)
 
void SetLESignal (int a_polyref, LE_Signal a_signal)
 
void IncTreatCounter (int a_treat)
 
TTypesOfLandscapeElement TranslateEleTypes (int EleReference)
 
TTypesOfVegetation TranslateVegTypes (int VegReference)
 
LESupplyLEPointer (int a_polyref)
 
int BackTranslateEleTypes (TTypesOfLandscapeElement EleReference)
 
int BackTranslateVegTypes (TTypesOfVegetation VegReference)
 
std::string EventtypeToString (int a_event)
 
std::string PolytypeToString (TTypesOfLandscapeElement a_le_type)
 
std::string VegtypeToString (TTypesOfVegetation a_veg)
 
void InitOsmiaBeeNesting ()
 Read in the Osmia nest density files and allocate to each LE object. More...
 
void UpdateOsmiaNesting ()
 Tesll all LE objects to update their osmia nest status. More...
 
bool SupplyOsmiaNest (int a_x, int a_y)
 Find out whether an osmia nest can be made here. More...
 
void IncOsmiaNest (int a_x, int a_y)
 Reopen the osmia nest here
More...
 
void ReleaseOsmiaNest (int a_x, int a_y)
 Reopen the osmia nest here
More...
 

Protected Member Functions

void GISASCII_Output (string outpfile, int UTMX, int UTMY)
 Write ASCII file of the ALMaSS map. More...
 
void AddGreenElement (LE *a_green)
 
void ReadPolys (const char *a_polyfile)
 
void ReadPolys2 (const char *a_polyfile)
 reads in polygon information. Version 2 including centroid and openness information More...
 
void PolysValidate (bool a_exit_on_invalid)
 
bool PolysRemoveInvalid (void)
 
void PolysDump (const char *a_filename)
 
void DumpMap (const char *a_filename)
 
void ConsolidatePolys (void)
 
void CountMapSquares (void)
 
void PolysRenumber (void)
 
void RebuildPolyMapping ()
 
void ForceArea (void)
 
void ChangeMapMapping (void)
 
LENewElement (TTypesOfLandscapeElement a_type)
 
void RemoveMissingValues ()
 A method for replacing missing values in the map with corrected ones - slow. More...
 
void TestCropManagement (void)
 
void VegDump (int x, int y)
 
void EventDump (int x, int y, int x2, int y2)
 
void EventDumpPesticides (int x1, int y1)
 
void DegreesDump ()
 Prints the sum of day degrees. See FarmManager::daydegrees. More...
 
bool BorderNeed (TTypesOfLandscapeElement a_letype)
 
void BorderAdd (LE *a_field, TTypesOfLandscapeElement a_type)
 
void BorderRemoval (void)
 
int RemoveSmallPolygons (void)
 Removes small polygons from the map. More...
 
void CreatePondList ()
 Creates a list of pond polygon refs/indexes for easy look up. More...
 
void UnsprayedMarginAdd (LE *a_field)
 
void UnsprayedMarginScan (LE *a_field, int a_width)
 
void BorderScan (LE *a_field, int a_width)
 
bool BorderTest (int a_fieldpoly, int a_borderpoly, int a_x, int a_y)
 
bool StepOneValid (int a_polyindex, int a_x, int a_y, int step)
 
bool UMarginTest (int a_fieldpoly, int a_borderpoly, int a_x, int a_y, int a_width)
 
bool FindValidXY (int a_field, int &a_x, int &a_y)
 
bool BorderStep (int a_fieldpoly, int a_borderpoly, int *a_x, int *a_y)
 
bool BorderStep (int a_fieldpoly, int a_borderpoly, APoint *a_coord)
 
void AddBeetleBanks (TTypesOfLandscapeElement a_tole)
 
bool BeetleBankPossible (LE *a_field, TTypesOfLandscapeElement a_tole)
 
void BeetleBankAdd (int x, int y, int angle, int length, LE *a_field, TTypesOfLandscapeElement a_tole)
 
bool FindFieldCenter (LE *a_field, int *x, int *y)
 
int FindLongestAxis (int *x, int *y, int *a_length)
 
void AxisLoop (int a_poly, int *a_x, int *a_y, int a_axis)
 
void AxisLoop (int a_poly, APoint *a_cor, int a_axis)
 
void AxisLoopLtd (int a_poly, APoint *a_cor, int a_axis, int a_limit)
 
void hb_Add (void)
 
void hb_AddNewHedgebanks (int a_orig_poly_num)
 
int hb_StripingDist (void)
 
void hb_GenerateHBPolys (void)
 
void hb_FindHedges (void)
 
bool hb_FindBoundingBox (int a_poly_num)
 
void hb_UpPolyNumbers (void)
 
void hb_ClearPolygon (int a_poly_num)
 
void hb_PaintBorder (int a_color)
 
bool hb_MapBorder (int a_x, int a_y)
 
bool hb_HasOtherNeighbour (int a_x, int a_y)
 
bool hb_PaintWhoHasNeighbourColor (int a_neighbour_color, int a_new_color)
 
bool hb_HasNeighbourColor (int a_x, int a_y, int a_neighbour_color)
 
void hb_MarkTopFromLocalMax (int a_color)
 
void hb_MarkTheBresenhamWay (void)
 
int hb_MaxUnpaintedNegNeighbour (int a_x, int a_y)
 
void hb_ResetColorBits (void)
 
void hb_RestoreHedgeCore (int a_orig_poly_number)
 
void hb_DownPolyNumbers (void)
 
void hb_Cleanup (void)
 
void DumpMapGraphics (const char *a_filename)
 
void DumpTreatCounters (const char *a_filename)
 
bool CIPELandscapeMaker ()
 

Protected Attributes

int m_treatment_counts [last_treatment]
 
int m_LargestPolyNumUsed
 
vector< int > m_PondIndexList
 List of pond indexes. More...
 
vector< int > m_PondRefsList
 List of pond polyrefs. More...
 
vector< int > hb_hedges
 
vector< LE * > hb_new_hbs
 
int m_x_add [8]
 
int m_y_add [8]
 
int * hb_map
 
int hb_width
 
int hb_height
 
int hb_size
 
int hb_min_x
 
int hb_max_x
 
int hb_min_y
 
int hb_max_y
 
int hb_first_free_poly_num
 
int hb_core_pixels
 
int hb_border_pixels
 
TTypesOfPesticide m_PesticideType
 An attribute to hold the pesticide type being tested, if there is one, if not default is -1. More...
 
bool m_toxShouldSpray
 
int le_signal_index
 

Private Attributes

char m_versioninfo [30]
 
FarmManagerm_FarmManager
 List of all the farms. More...
 
vector< LE * > m_elems
 List of all landscape elements. The index is a sequential number, to get the polynum look this number up in m_polymapping. More...
 
RasterMapm_land
 The big map. More...
 
vector< int > m_polymapping
 
PesticideMapm_PesticideMap
 For specialised pesticide recording. More...
 
int m_width
 
int m_height
 
int m_width10
 
int m_height10
 
int m_minmaxextent
 
int m_maxextent
 
bool m_NeedCentroidCalculation
 a flag to ensure centroid calculation on object construction More...
 
bool m_NeedOpennessCalculation
 a flag to ensure openness calculation on object construction More...
 
bool m_DoMissingPolygonsManipulations
 
double * l_vegtype_areas
 
Population_Managerm_ThePopManager
 a pointer to the current main population manager More...
 
RodenticideManagerm_RodenticideManager
 
RodenticidePredators_Population_Managerm_RodenticidePreds
 
Polynomial2CurveClassm_GooseIntakeRateVSVegetationHeight_PF
 Curve relatning goose intake rates in KJ/min to vegetation height. More...
 
Polynomial2CurveClassm_GooseIntakeRateVSVegetationHeight_BG
 
Polynomial2CurveClassm_GooseIntakeRateVSVegetationHeight_GL
 

Detailed Description

The landscape class containing all environmental and topographical data.

Constructor & Destructor Documentation

◆ ~Landscape()

Landscape::~Landscape ( void  )
1424  {
1427  }
1428 
1429 #ifdef __RECORDFARMEVENTS
1430  m_farmeventfile->close();
1431  delete m_farmeventfile;
1432 #endif
1433 
1434  for ( unsigned int i = 0; i < m_elems.size(); i++ )
1435  delete m_elems[ i ];
1436 
1437  free( l_vegtype_areas );
1438  delete m_land;
1439  //delete g_rotation;
1440  delete g_crops;
1441  delete g_letype;
1442  delete g_weather;
1443  delete g_date;
1444  delete g_pest;
1446  {
1447  delete m_RodenticideManager;
1448  delete m_RodenticidePreds;
1449  }
1450  delete m_FarmManager;
1451  delete g_msg; // Must be last.
1452 }
static CfgStr l_map_dump_treatcounts_file("MAP_DUMP_TREATCOUNTS_FILE", CFG_CUSTOM, "treatment_counts.txt")
static CfgBool l_map_dump_treatcounts_enable("MAP_DUMP_TREATCOUNTS_ENABLE", CFG_CUSTOM, false)
CfgBool cfg_rodenticide_enable("RODENTICIDE_ENABLE", CFG_CUSTOM, false)
class Calendar * g_date
Definition: calendar.cpp:38
bool value(void)
Definition: configurator.h:135
const char * value(void)
Definition: configurator.h:152
FarmManager * m_FarmManager
List of all the farms.
Definition: landscape.h:119
RodenticideManager * m_RodenticideManager
Definition: landscape.h:157
void DumpTreatCounters(const char *a_filename)
Definition: Landscape.cpp:3586
double * l_vegtype_areas
Definition: landscape.h:153
RodenticidePredators_Population_Manager * m_RodenticidePreds
Definition: landscape.h:158
vector< LE * > m_elems
List of all landscape elements. The index is a sequential number, to get the polynum look this number...
Definition: landscape.h:122
RasterMap * m_land
The big map.
Definition: landscape.h:125
class LE_TypeClass * g_letype
Definition: elements.cpp:277
class Pesticide * g_pest
Definition: pesticide.cpp:92
class MapErrorMsg * g_msg
This pointer provides access the to the internal ALMaSS error message system.
Definition: maperrormsg.cpp:41
class PlantGrowthData * g_crops
Definition: plants.cpp:41
class Weather * g_weather
Definition: weather.cpp:41

References cfg_rodenticide_enable, g_crops, g_date, g_letype, g_msg, g_pest, g_weather, l_map_dump_treatcounts_enable, l_map_dump_treatcounts_file, CfgBool::value(), and CfgStr::value().

◆ Landscape()

Landscape::Landscape ( void  )

If the farmer decision making model is on, the FarmManager::InitFarms() is called here to initialise the farms. The FarmManager::FindNeighbours() function is called.

Next job after checking the basic map validity is to deal with any missing polygon information This is done by identifying the polygons that are large contiguous areas and making them wasteland. The rest are left and nibbled away to join adjacent polygons. This is a time consuming operation so is only done if there have been any missing info polygons found.

To be sure we have enough space to do map manipulations if required, then the polygons need to be renumbered - unless they are done already.

Rodenticide handling code. If enabled then rodenticide mapping provides access to predicted relative density of poisoned rodents per unit area.

814  {
815 
818  // Set up operation flags
819  bool didRenumber = false;
820  bool didCalcCentroids = false;
821  bool didConsolidate = false;
822  bool didCalcOpenness = false;
823  bool didCalcOther = false;
827  // Set up globals
828  g_landscape_p = this;
829  for (int i = 1; i <= 2000; i++) {
830  g_SpeedyDivides[i] = 1 / double(i);
831  }
832  int x_add[8] = { 1, 1, 0, -1, -1, -1, 0, 1 }; // W,SW,S,SE,E,NE,N,NW
833  int y_add[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
834  for (int i = 0; i < 8; i++) {
835  m_x_add[i] = x_add[i];
836  m_y_add[i] = y_add[i];
837  }
838 
839 
841 
843  printf("This program uses the Landscape simulator V%s\n", m_versioninfo);
844  }
845 #ifdef __GITVERSION
847  {
848  std::cout << "hash=" << GIT_HASH << ", time=" << COMPILE_TIME << ", branch=" << GIT_BRANCH << std::endl;
849  }
850 #endif
851 
852 
853  // For testing.
854  //g_cfg->DumpPublicSymbols( "publicsymbols.cfg", CFG_PUBLIC );
855  //exit(1);
856 
857  //Pinkfeet
859  //Barnacle
861  //Greylag
863  if (cfg_WriteCurve.value()) {
867  }
868 
869  cout << "Creating Calendar Object" << endl;
870  g_date = new Calendar;
871  cout << "Creating Weather Object" << endl;
873  cout << "Creating LE_TypeClass Object" << endl;
874  g_letype = new LE_TypeClass;
875  cout << "Creating PlantGrowthData Object" << endl;
877  cout << "Creating PollenNectarDevelopmentData Object" << endl;
878  g_nectarpollen = new PollenNectarDevelopmentData("toleALMaSSNectarPollenInput.txt", "tovALMaSSNectarPollenInput.txt", this);
880 
881  // Reset treatment counters.
882  for (int i = 0; i < last_treatment; i++) {
883  m_treatment_counts[i] = 0;
884  }
885  cout << "Creating FarmManager Object" << endl;
886  m_FarmManager = new FarmManager();
887 
888  cout << "Reading polygon reference file" << endl;
890 
891  //this carries out the optimisation
892  if (cfg_OptimisingFarms.value()){
895  }
896 
897  cout << "Creating RasterMap Object" << endl;
898  m_land = new RasterMap(l_map_map_file.value(), this);
899  m_width = m_land->MapWidth();
902  m_width10 = 10 * m_width;
903  m_height10 = 10 * m_height;
905 
906 
907  // Validate polygons, ie. ensure those reference in the
908  // polygon file also shows up in the map.
909  cout << "In PolysValidate" << endl;
910  PolysValidate(false);
911  cout << "In PolysRemoveInvalid" << endl;
913  cout << "Creating ponds" << endl;
914  if (cfg_MaxPondSize.value() > 0) {
915  // This takes any small freshwater and converts it to a pond.
916  for (unsigned int i = 0; i < m_elems.size(); i++) {
917  if (m_elems[i]->GetElementType() == tole_Freshwater) {
918  if (m_elems[i]->GetArea() <= cfg_MaxPondSize.value()) {
919  Pond* pond = new Pond;
920  pond->DoCopy(m_elems[i]);
922  pond->SetElementType(tole_Pond);
923  m_elems[i] = dynamic_cast<LE*>(pond);
924  }
925  }
926  }
927  }
928  cout << "In PolysValidate second time" << endl;
929  PolysValidate(true);
930 
937  {
938  cout << "In DoMissingPolygonsManipulations" << endl;
939  // Find big continuous polygons
940  for (unsigned int i = 0; i < m_elems.size(); i++)
941  {
942  if (m_elems[i]->GetElementType() == tole_Missing)
943  {
944  double area = m_elems[i]->GetArea();
945  int areaMinrect = (m_elems[i]->GetMaxX() - m_elems[i]->GetMinX()) * (m_elems[i]->GetMaxY() - m_elems[i]->GetMinY());
946  if ((areaMinrect / area > 4) || (area < 1000))
947  {
948  // Unlikely to be a field, or if so a very narrow odd one. We will assume this is a missing data issue.
949  }
950  else
951  {
952  // Big poly with more than 25% of the included rectangle covered, must be a field of some sort.
953  // create a new wasteland and swap this in to the m_elems, then delete the old missing polygon
954  LE * wl = NewElement(tole_Wasteland);
955  wl->SetPoly(m_elems[i]->GetPoly());
956  wl->SetArea(floor(0.5 + area));
957  wl->SetSoilType(m_elems[i]->GetSoilType());
959  wl->SetCentroid(-1, -1);
960  wl->SetOpenness(0);
961  delete m_elems[i];
962  m_elems[i] = wl;
963  }
964  }
965  }
966  // By here all the big ones should be safely tidied away to wasteland and now we need to deal with the raster map.
968  for (unsigned int i = 0; i < m_elems.size(); i++)
969  {
970  // Now we deal with all the little ones that were not by fields
971  if (m_elems[i]->GetElementType() == tole_Missing)
972  {
973  LE * wl = NewElement(tole_Wasteland);
974  wl->SetPoly(m_elems[i]->GetPoly());
975  wl->SetArea(m_elems[i]->GetArea());
976  wl->SetSoilType(m_elems[i]->GetSoilType());
978  wl->SetCentroid(-1, -1);
979  wl->SetOpenness(0);
980  delete m_elems[i];
981  m_elems[i] = wl;
982  }
983  }
984  cout << "In PolysValidate third time" << endl;
985  PolysValidate(false);
986  if (PolysRemoveInvalid()) {
987  cout << "In PolysValidate fourth time" << endl;
988  PolysValidate(true);
989  }
990  g_msg->Warn("Landscape::Landscape(): Dump and normal exit to follow after resolving missing polygons. ", "");
991  didCalcOther = true;
992  }
993 
994  // ChangeMapMapping() also enters a valid starting
995  // coordinate for the border generating farm method below.
996  cout << "In ChangeMapMapping" << endl;
998 
1002  if ((m_LargestPolyNumUsed != ((int)m_elems.size() - 1)))
1003  {
1004  cout << "In poly renumber" << endl;
1005 
1006  PolysRenumber();
1007  didRenumber = true;
1008  }
1009  // do we want to remove small polygons?
1011  {
1012  cout << "In Landscape::Landscape() Small polygon removal" << endl;
1013  int removed = RemoveSmallPolygons();
1014  g_msg->Warn("Landscape::Landscape(): Dump and normal exit to follow after removing small polygons and map dump. Polygons removed:", removed);
1015  didCalcOther = true;
1016  }
1017  // Do we want to re-write the current files and consolidate polys?
1018  else if (l_map_consolidatepolys.value())
1019  {
1020  cout << "In consolidate polys" << endl;
1021  didConsolidate = true;
1022  ConsolidatePolys();
1023  }
1024  else if (g_map_le_borderremoval.value())
1025  {
1026  cout << "In map_le_borderremoval" << endl;
1027  // Does not use centroids so is safe to use here
1028  BorderRemoval();
1029  CountMapSquares();
1030  ForceArea();
1031  g_msg->Warn(WARN_FILE, "Landscape::Landscape() - BorderRemoval "" map dump to follow.", "");
1032  didCalcOther = true;
1033  }
1034 
1035 
1036  // By the time we reach this point we need to have completed all major polygon removal and are ready to calculate centroids if they are needed. There
1037  // are two reasons for this - 1) that we did not have them in the original polyref file, 2) that we changed the map
1038  if (didConsolidate || didCalcOther || m_NeedCentroidCalculation)
1039  {
1040  PolysValidate(false);
1041  if (PolysRemoveInvalid()) PolysValidate(true);
1042  ChangeMapMapping();
1043  PolysRenumber();
1045  didCalcCentroids = true;
1046  }
1047  if (didConsolidate || didCalcOther || m_NeedCentroidCalculation || didCalcCentroids || l_map_calc_openness.value())
1048  {
1050  else CalculateOpenness(false);
1051  didCalcOpenness = true;
1052  }
1053  if (didCalcCentroids || didConsolidate || didCalcOpenness || didCalcOther || m_NeedCentroidCalculation || didRenumber || !m_FarmManager->GetIsRenumbered())
1054  {
1055  // We need to dump the map and polyrefs
1059  g_msg->Warn(WARN_FILE, "Landscape::Landscape() ""Normal exit after dump.", "Remember to rename the new map and polyref file.");
1060  exit(0);
1061  }
1062 
1063  // Below here we have the more complicated map manipulations. These will need recalculation of centroids and openness after they are run.
1064  // However, we really do not want to get here with invalid centroids, hence forced dump and exit for manipulations up to this point.
1065 
1066  didCalcOther = false;
1067  // Add artificial hedgebanks to the hedges in the landscape,
1068  // if requested.
1069  if (l_map_art_hedgebanks.value()) {
1070  hb_Add();
1071  didCalcOther = true;
1072  }
1073  else if (g_map_le_borders.value())
1074  {
1075  cout << "Generating LE Borders around fields" << endl;
1076  cout << "Border chance = " << g_map_le_border_chance.value() << endl;
1077  cout << "Border width = " << g_map_le_borderwidth.value() << endl;
1078  // Generate border around each *farm* landscape element.
1079  cout << "Setting MaxMin Extents" << endl;
1081  cout << "Adding Borders" << endl;
1082  unsigned sz = (unsigned)m_elems.size();
1083  for (unsigned i = 0; i < sz; i++)
1084  {
1085  if (m_elems[i]->GetBorder() != NULL)
1086  {
1087  // Border around this element, so must be a farm field.
1088  // If the field is too small then ignore it
1089  if (m_elems[i]->GetArea() > g_map_le_borders_min_field_size.value())
1090  {
1092  BorderAdd(m_elems[i], t);
1093  }
1094  }
1095  }
1096  didCalcOther = true;
1097  }
1098  else // Some special code to 'soften' the edges of orchards
1100  {
1101  // Generate border around each *farm* landscape element.
1102  for (unsigned int i = 0; i < m_elems.size(); i++) {
1103  if (m_elems[i]->GetElementType() == tole_Orchard)
1104  {
1106  BorderAdd(m_elems[i], t);
1107  }
1108  }
1109  didCalcOther = true;
1110  }
1111  else
1112  // Unsprayed Margin Code....
1114  {
1115  CountMapSquares();
1116  ForceArea();
1117 
1118  // Generate border around each *farm* landscape element.
1119  for (unsigned int i = 0; i < m_elems.size(); i++)
1120  {
1121  if (m_elems[i]->GetUnsprayedMarginPolyRef() != -1)
1122  {
1123  // But not if the field is too small to have them (<1Ha)
1124  if (m_elems[i]->GetArea() > 10000)
1125  {
1126  // Border around this element, so must be a farm field.
1128  }
1129  else m_elems[i]->SetUnsprayedMarginPolyRef(-1);
1130  }
1131  }
1132  didCalcOther = true;
1133  }
1134  else if (cfg_AddBeetleBanks.value())
1135  {
1136  cout << "Adding beetle banks now" << endl;
1138  didCalcOther = true;
1139  }
1140 
1142  {
1144  }
1145 
1146  if (l_map_dump_enable.value() || didCalcOther)
1147  {
1148  CountMapSquares();
1149  ForceArea();
1150  PolysValidate(false);
1151  if (PolysRemoveInvalid()) PolysValidate(true);
1152  ChangeMapMapping();
1153  PolysRenumber();
1157  cout << "Dumping map" << endl;
1159  cout << "Dumping polygon refs file" << endl;
1161  g_msg->Warn(WARN_FILE, "Landscape::Landscape() ""Normal exit after dump.", "Remember to rename the new map and polyref file.");
1162  exit(0);
1163  }
1164 
1165  /*'''''''''''''''''' CIPE LANDSCAPE MAKER CODE HERE //'''''''''''''''''''''
1166  if ( l_map_CIPEmaker_enable.value() ) {
1167  CIPELandscapeMaker();
1168  if ( l_map_dump_exit.value() ) {
1169  g_msg->Warn( WARN_FILE, "Landscape::Landscape(): ""Normal exit after map dump.", "" );
1170  exit( 0 );
1171  }
1172  }
1173  //'''''''''''''''''' CIPE LANDSCAPE MAKER CODE ABOVE //'''''''''''''''''''''
1174  */
1175  // Set the type of hedgebanks.
1176  int l_subtype = cfg_HedgeSubtypeMinimum.value();
1177  for (unsigned int i = 0; i < m_elems.size(); i++) {
1178  if (m_elems[i]->GetElementType() == tole_HedgeBank) {
1179  m_elems[i]->SetSubType(l_subtype);
1180  if (++l_subtype >= cfg_HedgeSubtypeMaximum.value())
1181  l_subtype = cfg_HedgeSubtypeMinimum.value();
1182  }
1183  }
1184 
1185  // And another to set the type of hedges
1186  // ***CJT*** 2003-12-02
1187  l_subtype = 0;
1188  for (unsigned int i = 0; i < m_elems.size(); i++) {
1189  if (m_elems[i]->GetElementType() == tole_Hedges) {
1190  m_elems[i]->SetSubType(l_subtype);
1191  if (++l_subtype >= 3)
1192  l_subtype = 0;
1193  }
1194  }
1195  // Count up the ponds and store them now we are finished with polygon handling.
1196  CreatePondList();
1197 
1198  cout << "Initiating farm management" << endl;
1200  g_pest = new Pesticide(m_land, this);
1201  m_toxShouldSpray = false; // Flag for special pesticide tests
1203  g_date->Reset();
1204 
1205  /*
1206  if ( g_farm_test_crop.value() ) {
1207  TestCropManagement();
1208  exit( 0 );
1209  }
1210  */
1211 
1212  // Set up treatment flags
1213  // Reset internal state for the LE loop generator.
1214  // Compulsory!
1215  SupplyLEReset();
1216  // Get number of *all* landscape elements.
1217  int l_count = SupplyLECount();
1218 
1219  // Now loop through then.
1220  for (int i = 0; i < l_count; i++) {
1221  // Fetch next LE by its polygon reference number. Alternative
1222  // loop mechanism: This will return -1 at end-of-loop.
1223  int a_poly = SupplyLENext();
1224 
1225  // Skip uninteresting polygons by type, ownership,
1226  // phase of the moon, whatever.
1227  // if ( these_are_not_the_droids_we_are_looking_for( a_poly )) {
1228  if (SupplyElementType(a_poly) != tole_Field)
1229  continue;
1230 
1231  // Example: Set x% of them to ignore insecticide of all types.
1232  if (random(100) < l_map_no_pesticide_fields.value()) {
1233  // Get current signal mask for polygon.
1234  LE_Signal l_signal = SupplyLESignal(a_poly);
1235  // Logical OR in/AND out the signals you are interested in.
1236  // The current signals are at the top of elements.h
1237  //l_signal |= LE_SIG_NO_INSECTICIDE | LE_SIG_NO_SYNG_INSECT | LE_SIG_NO_HERBICIDE | LE_SIG_NO_FUNGICIDE | LE_SIG_NO_GROWTH_REG;
1238  //l_signal |= LE_SIG_NO_INSECTICIDE | LE_SIG_NO_SYNG_INSECT | LE_SIG_NO_HERBICIDE;
1239  // Write the mask back out to the polygon.
1240  SetLESignal(a_poly, l_signal);
1241  }
1242  }
1243 
1244  l_vegtype_areas = (double *)malloc(sizeof(double) * (tov_Undefined + 1));
1245 
1246  if (l_vegtype_areas == NULL) {
1247  g_msg->Warn(WARN_BUG, "Landscape::Landscape(): Out of memory!", "");
1248  exit(1);
1249  }
1250  FILE * outf;
1251  if (cfg_dumpvegjan.value()) {
1252  outf = fopen(cfg_dumpvegjanfile.value(), "w");
1253  if (!outf) {
1254  g_msg->Warn(WARN_FILE, "Landscape::DumpMapInfoByArea(): ""Unable to create file", cfg_dumpvegjanfile.value());
1255  exit(1);
1256  }
1257  else
1258  fclose(outf);
1259  }
1260 
1261  if (cfg_dumpvegjune.value()) {
1262  outf = fopen(cfg_dumpvegjunefile.value(), "w");
1263  if (!outf) {
1264  g_msg->Warn(WARN_FILE, "Landscape::DumpMapInfoByArea(): ""Unable to create file", cfg_dumpvegjunefile.value());
1265  exit(1);
1266  }
1267  else
1268  fclose(outf);
1269  }
1270 
1271 #ifdef __RECORDFARMEVENTS
1272  m_farmeventfile = new ofstream("FarmEvents.txt", ofstream::out);
1273 #endif
1274 
1275 
1276  // Dump veg information if necessary
1277  if (l_map_dump_veg_enable.value()) {
1278  FILE * f;
1279  f = fopen("VegDump.txt", "w");
1280  if (!f) {
1281  g_msg->Warn(WARN_BUG, "Landscape::Landscape(): VegDump.txt could not be created", "");
1282  exit(1);
1283  }
1284  fprintf(f, "Year\tDay\tHeight\tBiomass\tGrazed\tDensity\tCover\tWeedBiomass\ttovNum\tInsectBiomass\tLATotal\tLAGreen\tDigestability\tGreenBiomass\tDeadBiomass\tGooseGrazing\tSpilledGrain\nn");
1285  fclose(f);
1286  }
1288  FILE * f;
1289  f = fopen("EventDump.txt", "w");
1290  if (!f) {
1291  g_msg->Warn(WARN_BUG, "Landscape::Landscape(): EventDump.txt could not be created", "");
1292  exit(1);
1293  }
1294  fclose(f);
1295  }
1296 
1299  }
1300 
1301  if (cfg_DumpFarmAreas.value()){
1303  }
1304 
1305  // If we are testing a pesticide then set the enum attribute
1307 
1310  {
1311  m_RodenticideManager = new RodenticideManager("BaitLocations_input.txt", this);
1313  }
1314 
1315  // Run a year to remove any start up effects
1316  cout << "Running initial start-up year" << endl;
1317  for (unsigned int i = 0; i < 365; i++) Tick();
1318  //switch the rotation after running the hidden year (only for optimising farms), AM, 030713
1320  // Write ASCII file:
1321  if (l_map_write_ascii.value()) {
1322  int x = l_map_ascii_utm_x.value();
1323  int y = l_map_ascii_utm_y.value();
1324  GISASCII_Output("AsciiLandscape.txt", x, y);
1325  }
1326 }
int random(int a_range)
Definition: ALMaSS_CmdLine.cpp:142
static const int version_minor
Definition: Landscape.cpp:50
static CfgBool l_map_removesmallpolygons("MAP_REMOVESMALLPOLYGONS", CFG_CUSTOM, false)
CfgBool cfg_dumpvegjan("G_VEGAREASJAN_ON", CFG_CUSTOM, false)
CfgInt cfg_pesticidemapcellsize("PEST_MAP_CELLSIZE", CFG_CUSTOM, 10)
The output cell size for pesticides - a performance penalty if this does not match the pesticide cell...
CfgFloat cfg_P1A
CfgFloat cfg_G6G
static CfgInt l_map_no_pesticide_fields("MAP_NO_PESTICIDE_FIELDS", CFG_CUSTOM, 0)
static CfgStr l_map_map_file("MAP_MAP_FILE", CFG_CUSTOM, "map.lsb")
CfgStr cfg_B6H
CfgFloat cfg_B6G
CfgStr l_map_dump_poly_file("MAP_DUMP_POLY_FILE", CFG_CUSTOM, "dump_polyrefs.txt")
CfgStr cfg_G6H
CfgInt cfg_pesticidemapstartyear("PEST_MAP_STARTYEAR", CFG_CUSTOM, 0)
The first simulation year the pesticide is mapped.
CfgBool cfg_G6E
static CfgBool l_map_dump_gfx_enable("MAP_DUMP_GFX_ENABLE", CFG_CUSTOM, false)
static CfgBool l_map_art_hedgebanks("MAP_ART_HEDGEBANKS", CFG_CUSTOM, false)
CfgFloat cfg_G6B
CfgFloat cfg_P1C
CfgStr l_map_dump_map_file("MAP_DUMP_MAP_FILE", CFG_CUSTOM, "dump.lsb")
CfgBool cfg_P1E
static CfgBool l_map_consolidatepolys("MAP_CONSOLIDATEPOLYS", CFG_CUSTOM, false)
Used to consolidate polygons with no special behaviour into a single polygon of that type.
CfgBool cfg_pesticidemaptype("PEST_MAP_TYPE", CFG_CUSTOM, false)
True for specific pesticide, false for general pesticides.
CfgBool cfg_B6E
CfgFloat cfg_B6F
CfgBool cfg_pesticidemapon("PEST_MAP_ON", CFG_CUSTOM, false)
Flag determining whether we are using the pesticide map.
static CfgStr l_map_dump_gfx_file("MAP_DUMP_GFX_FILE", CFG_CUSTOM, "dump.ppm")
static CfgBool l_map_dump_event_enable("MAP_DUMP_EVENT_ENABLE", CFG_CUSTOM, false)
CfgFloat cfg_G6F
static CfgStr l_map_weather_file("MAP_WEATHER_FILE", CFG_CUSTOM, "weather.pre")
CfgStr cfg_dumpvegjanfile("G_VEGAREASJAN_FILENAME", CFG_CUSTOM, "DUMPVEG_JAN.TXT")
CfgBool l_map_print_git_version_info("MAP_PRINT_GIT_VERSION_INFO", CFG_CUSTOM, false)
Should git version info be printed to file and console?
static CfgBool l_map_calc_openness("MAP_CALC_OPENNESS", CFG_CUSTOM, false)
static CfgBool l_map_dump_enable("MAP_DUMP_ENABLE", CFG_CUSTOM, false)
CfgBool cfg_WriteCurve
CfgBool cfg_OptimiseBedriftsmodelCrops
static const int version_revision
Definition: Landscape.cpp:51
CfgFloat cfg_P1D
static CfgInt l_map_ascii_utm_x("MAP_ASCII_UTM_X", CFG_CUSTOM, 0)
If we write an ASCII file provide UTM-x of lower lefthand corner.
Landscape * g_landscape_p
Definition: Landscape.cpp:258
static CfgBool l_map_dump_veg_enable("MAP_DUMP_VEG_ENABLE", CFG_CUSTOM, true)
static CfgBool cfg_AddBeetleBanks("BBANKS_ADD", CFG_CUSTOM, false)
CfgInt cfg_HedgeSubtypeMinimum("HEDGE_SUBTYPEMINIMUM", CFG_CUSTOM, 0)
static CfgStr l_map_poly_file("MAP_POLY_FILE", CFG_CUSTOM, "polygonrefs.txt")
PollenNectarDevelopmentData * g_nectarpollen
Definition: Landscape.cpp:241
CfgFloat cfg_G6C
CfgFloat cfg_P1G
static CfgStr l_map_cropcurves_file("MAP_CROPCURVES_FILE", CFG_CUSTOM, "curves.pre")
CfgBool cfg_OptimisingFarms
static const char * version_date
Definition: Landscape.cpp:52
CfgBool cfg_DumpFarmAreas
CfgFloat cfg_G6A
CfgStr cfg_P1H
static const int version_major
Definition: Landscape.cpp:49
CfgFloat cfg_B6A
static CfgInt cfg_BeetleBankType("BBANK_TYPE", CFG_CUSTOM,(int) tole_BeetleBank)
static CfgBool l_map_print_version_info("MAP_PRINT_VERSION_INFO", CFG_CUSTOM, true)
CfgInt cfg_HedgeSubtypeMaximum("HEDGE_SUBTYPEMAXIMUM", CFG_CUSTOM, 3)
CfgStr cfg_dumpvegjunefile("G_VEGAREASJUNE_FILENAME", CFG_CUSTOM, "DUMPVEG_JUNE.TXT")
CfgFloat cfg_B6D
static CfgInt cfg_MaxPondSize("MAP_MAXPONDSIZE", CFG_CUSTOM, 5000)
If freshwater area is below this it is designated a pond.
CfgFloat cfg_B6C
CfgInt cfg_pesticidetesttype("PESTICIDETESTYPE", CFG_CUSTOM, -1)
static CfgBool l_map_write_ascii("MAP_WRITE_ASCII", CFG_CUSTOM, false)
Used if an ASCII file for use in GIS applications should be written.
double g_SpeedyDivides[2001]
A generally useful array of fast divide calculators by multiplication.
Definition: Landscape.cpp:250
CfgFloat cfg_B6B
CfgFloat cfg_P1B
CfgFloat cfg_G6D
CfgInt cfg_pesticidemapnoyears("PEST_MAP_NOYEARS", CFG_CUSTOM, 1)
The numer of years of pesticide mapping.
static CfgInt l_map_ascii_utm_y("MAP_ASCII_UTM_Y", CFG_CUSTOM, 0)
If we write an ASCII file provide UTM-y of lower lefthand corner.
CfgFloat cfg_P1F
CfgBool cfg_dumpvegjune("G_VEGAREASJUNE_ON", CFG_CUSTOM, false)
Definition: calendar.h:39
void Reset(void)
Definition: calendar.cpp:40
double value(void)
Definition: configurator.h:118
int value(void)
Definition: configurator.h:98
virtual void WriteDataFile(int a_step)
Definition: CurveClasses.cpp:87
The Farm Manager class.
Definition: farm.h:1707
void InitFarms()
Calls OptimisingFarm::Init for all optimising farms.
Definition: farm.cpp:3014
void DumpFarmAreas()
Definition: farm.cpp:1964
void InitiateManagement(void)
Definition: farm.cpp:2733
void Save_diff_farm_types_areas()
Calculates and saves total areas of all optimising farms and specific farm types.
Definition: farm.cpp:3404
void FindNeighbours()
Finds all OptimisingFarms' neighbours and saves them in the farm's OptimisingFarm::m_neighbours vecto...
Definition: farm.cpp:4657
void Switch_rotation()
Switches OptimisingFarms Farm::m_rotation to the list of all possible rotational crops.
Definition: farm.cpp:4942
bool GetIsRenumbered()
Returns the flag for renumbering.
Definition: farm.h:1886
void DumpFarmrefs()
dumps the farmrefs file to a standard named file
Definition: farm.cpp:2997
Definition: elements.h:71
int BackTranslateEleTypes(TTypesOfLandscapeElement EleReference)
Definition: elements.cpp:3610
TTypesOfLandscapeElement TranslateEleTypes(int EleReference)
Definition: elements.cpp:2995
Definition: elements.h:81
void SetElementType(int a_type)
Definition: elements.h:114
void SetPoly(int a_poly)
Definition: elements.h:226
void SetArea(double a_area)
Definition: elements.h:229
void SetOpenness(int a_openness)
Records the openness statistic for this polygon.
Definition: elements.h:380
void SetUnsprayedMarginPolyRef(int a_unsprayedmargin)
Definition: elements.h:322
void DoCopy(const LE *a_Le)
a copy function to be used because a copy constuctor won't work
Definition: elements.cpp:372
void SetSoilType(int a_st)
Definition: elements.h:287
void SetALMaSSEleType(int a_type)
Definition: elements.h:112
virtual void SetCentroid(int x, int y)
Definition: elements.h:139
bool m_NeedOpennessCalculation
a flag to ensure openness calculation on object construction
Definition: landscape.h:148
int m_height10
Definition: landscape.h:141
void ChangeMapMapping(void)
Definition: Landscape.cpp:2130
int m_LargestPolyNumUsed
Definition: landscape.h:194
int m_width
Definition: landscape.h:138
bool m_DoMissingPolygonsManipulations
Definition: landscape.h:150
int m_height
Definition: landscape.h:139
int RemoveSmallPolygons(void)
Removes small polygons from the map.
Definition: Landscape.cpp:2184
PesticideMap * m_PesticideMap
For specialised pesticide recording.
Definition: landscape.h:133
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_BG
Definition: landscape.h:161
void CalculateOpenness(bool a_realcalc)
Causes openness to be calulated and stored for all polygons.
Definition: Landscape.cpp:322
void CountMapSquares(void)
Definition: Landscape.cpp:2040
void SupplyLEReset(void)
Definition: Landscape.cpp:3551
void DumpMapGraphics(const char *a_filename)
Definition: Landscape.cpp:3599
int m_minmaxextent
Definition: landscape.h:142
int SupplyLENext(void)
Definition: Landscape.cpp:3555
void CreatePondList()
Creates a list of pond polygon refs/indexes for easy look up.
Definition: Landscape.cpp:2594
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_GL
Definition: landscape.h:162
void SetLESignal(int a_polyref, LE_Signal a_signal)
Definition: Landscape.cpp:3570
bool m_toxShouldSpray
Definition: landscape.h:317
TTypesOfPesticide m_PesticideType
An attribute to hold the pesticide type being tested, if there is one, if not default is -1.
Definition: landscape.h:278
char m_versioninfo[30]
Definition: landscape.h:115
void PolysRenumber(void)
Definition: Landscape.cpp:2057
int m_width10
Definition: landscape.h:140
LE * NewElement(TTypesOfLandscapeElement a_type)
Definition: Landscape.cpp:3688
void BorderRemoval(void)
Definition: Landscape.cpp:2271
void GISASCII_Output(string outpfile, int UTMX, int UTMY)
Write ASCII file of the ALMaSS map.
Definition: Landscape.cpp:3507
void AddBeetleBanks(TTypesOfLandscapeElement a_tole)
Definition: Landscape.cpp:2723
int m_y_add[8]
Definition: landscape.h:267
void Tick(void)
Definition: Landscape.cpp:1467
void SetPolyMaxMinExtents(void)
Definition: Landscape.cpp:1622
void RemoveMissingValues()
A method for replacing missing values in the map with corrected ones - slow.
Definition: Landscape.cpp:2090
void ConsolidatePolys(void)
Definition: Landscape.cpp:1329
int m_maxextent
Definition: landscape.h:143
void ForceArea(void)
Definition: Landscape.cpp:2072
int m_treatment_counts[last_treatment]
Definition: landscape.h:193
bool m_NeedCentroidCalculation
a flag to ensure centroid calculation on object construction
Definition: landscape.h:146
Polynomial2CurveClass * m_GooseIntakeRateVSVegetationHeight_PF
Curve relatning goose intake rates in KJ/min to vegetation height.
Definition: landscape.h:160
void ReadPolys2(const char *a_polyfile)
reads in polygon information. Version 2 including centroid and openness information
Definition: Landscape.cpp:1892
void BorderAdd(LE *a_field, TTypesOfLandscapeElement a_type)
Definition: Landscape.cpp:2347
int SupplyLECount(void)
Definition: Landscape.cpp:3562
void CalculateCentroids(void)
Definition: Landscape.cpp:3040
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1110
int m_x_add[8]
Definition: landscape.h:266
void PolysValidate(bool a_exit_on_invalid)
Definition: Landscape.cpp:1746
void PolysDump(const char *a_filename)
Definition: Landscape.cpp:1803
void hb_Add(void)
Definition: hedgebanks.cpp:56
void DumpMap(const char *a_filename)
Definition: Landscape.cpp:1386
LE_Signal SupplyLESignal(int a_polyref)
Definition: Landscape.cpp:3566
bool PolysRemoveInvalid(void)
Definition: Landscape.cpp:1772
void UnsprayedMarginAdd(LE *a_field)
Definition: Landscape.cpp:2617
void Warn(MapErrorState a_level, std::string a_msg1, std::string a_msg2)
Definition: maperrormsg.cpp:59
Definition: pesticide.h:107
Definition: pesticide.h:370
Definition: plants.h:81
A standard class to manage a range of pollen and nectar development curves based on indexed rates.
Definition: plants.h:225
A polynomial curve class.
Definition: CurveClasses.h:90
Ponds are defined as freshwater bodies between 25m2 and 5000m2. For newts the effective size is limit...
Definition: elements.h:1183
Definition: rastermap.h:41
int MapWidth(void)
Definition: rastermap.h:52
int MapHeight(void)
Definition: rastermap.h:53
Class for management of bait locations.
Definition: Rodenticide.h:73
Definition: RodenticidePredators.h:51
Definition: weather.h:386
unsigned int LE_Signal
Definition: elements.h:35
TTypesOfPesticide
Definition: landscape.h:66
CfgInt g_map_le_borderwidth("MAP_LE_BORDER_WIDTH", CFG_CUSTOM, 1)
CfgInt g_map_le_borderstype("MAP_LE_BORDERSTYPE", CFG_CUSTOM, 160)
CfgBool g_map_le_borderremoval("MAP_LE_BORDERREMOVAL", CFG_CUSTOM, false)
CfgBool g_map_le_borders("MAP_LE_BORDERS", CFG_CUSTOM, false)
CfgInt g_map_le_border_chance("MAP_LE_BORDER_CHANCE", CFG_CUSTOM, 25)
CfgInt g_map_le_borders_min_field_size("MAP_LE_BORDERS_MIN_FIELD_SIZE", CFG_CUSTOM, 10000)
CfgBool g_map_orchards_borders("MAP_ORCHARDS_BORDERS", CFG_CUSTOM, false)
CfgBool g_map_le_unsprayedmargins("MAP_LE_UNSPRAYEDMARGINS", CFG_CUSTOM, false)
@ WARN_BUG
Definition: maperrormsg.h:34
@ WARN_FILE
Definition: maperrormsg.h:37
TTypesOfLandscapeElement
Definition: tole_declaration.h:36
@ tole_Missing
Definition: tole_declaration.h:109
@ tole_Pond
Definition: tole_declaration.h:101
@ tole_Field
Definition: tole_declaration.h:43
@ tole_Hedges
Definition: tole_declaration.h:37
@ tole_Freshwater
Definition: tole_declaration.h:64
@ tole_Orchard
Definition: tole_declaration.h:71
@ tole_HedgeBank
Definition: tole_declaration.h:68
@ tole_Wasteland
Definition: tole_declaration.h:92
@ tov_Undefined
Definition: tov_declaration.h:114
@ last_treatment
Definition: treatment.h:113

References LE_TypeClass::BackTranslateEleTypes(), cfg_AddBeetleBanks, cfg_B6A, cfg_B6B, cfg_B6C, cfg_B6D, cfg_B6E, cfg_B6F, cfg_B6G, cfg_B6H, cfg_BeetleBankType, cfg_DumpFarmAreas, cfg_dumpvegjan, cfg_dumpvegjanfile, cfg_dumpvegjune, cfg_dumpvegjunefile, cfg_G6A, cfg_G6B, cfg_G6C, cfg_G6D, cfg_G6E, cfg_G6F, cfg_G6G, cfg_G6H, cfg_HedgeSubtypeMaximum, cfg_HedgeSubtypeMinimum, cfg_MaxPondSize, cfg_OptimiseBedriftsmodelCrops, cfg_OptimisingFarms, cfg_P1A, cfg_P1B, cfg_P1C, cfg_P1D, cfg_P1E, cfg_P1F, cfg_P1G, cfg_P1H, cfg_pesticidemapcellsize, cfg_pesticidemapnoyears, cfg_pesticidemapon, cfg_pesticidemapstartyear, cfg_pesticidemaptype, cfg_pesticidetesttype, cfg_rodenticide_enable, cfg_WriteCurve, LE::DoCopy(), g_crops, g_date, g_landscape_p, g_letype, g_map_le_border_chance, g_map_le_borderremoval, g_map_le_borders, g_map_le_borders_min_field_size, g_map_le_borderstype, g_map_le_borderwidth, g_map_le_unsprayedmargins, g_map_orchards_borders, g_msg, g_nectarpollen, g_pest, g_SpeedyDivides, g_weather, l_map_art_hedgebanks, l_map_ascii_utm_x, l_map_ascii_utm_y, l_map_calc_openness, l_map_consolidatepolys, l_map_cropcurves_file, l_map_dump_enable, l_map_dump_event_enable, l_map_dump_gfx_enable, l_map_dump_gfx_file, l_map_dump_map_file, l_map_dump_poly_file, l_map_dump_veg_enable, l_map_map_file, l_map_no_pesticide_fields, l_map_poly_file, l_map_print_git_version_info, l_map_print_version_info, l_map_removesmallpolygons, l_map_weather_file, l_map_write_ascii, last_treatment, random(), Calendar::Reset(), LE::SetALMaSSEleType(), LE::SetArea(), LE::SetCentroid(), LE::SetElementType(), LE::SetOpenness(), LE::SetPoly(), LE::SetSoilType(), LE::SetUnsprayedMarginPolyRef(), tole_Field, tole_Freshwater, tole_HedgeBank, tole_Hedges, tole_Missing, tole_Orchard, tole_Pond, tole_Wasteland, tov_Undefined, LE_TypeClass::TranslateEleTypes(), CfgInt::value(), CfgFloat::value(), CfgBool::value(), CfgStr::value(), version_date, version_major, version_minor, version_revision, MapErrorMsg::Warn(), WARN_BUG, and WARN_FILE.

Member Function Documentation

◆ AddBeetleBanks()

void Landscape::AddBeetleBanks ( TTypesOfLandscapeElement  a_tole)
protected

Beetle-bank addition - tests whether we can add a bank to this field, and then decides where to put it an adds it.

For each element, if it is a field then assess whether should have a beetle bank. This will depend on whether it is in the region defined for adding the bank, and a probability. This code requires polygon centroids to be active, either calculated or via l_map_read_openness == true.

To provide for more flexibilty, a tole_type is passed, and beetlebanks may be created of this tole_type instead of tole_BeetleBank

2723  {
2731  int BBs=0;
2732  int tx1 = cfg_BeetleBankMinX.value();
2733  int tx2 = cfg_BeetleBankMaxX.value();
2734  int ty1 = cfg_BeetleBankMinY.value();
2735  int ty2 = cfg_BeetleBankMaxY.value();
2736  bool doit = false;
2737  unsigned sz=(unsigned) m_elems.size();
2738  for (unsigned i=0; i<sz; i++)
2739  {
2740  if (m_elems[ i ]->GetElementType() == tole_Field)
2741  {
2742  doit = false;
2743  int cx = m_elems[ i ]->GetCentroidX();
2744  int cy = m_elems[ i ]->GetCentroidY();
2745  if (!cfg_BeetleBankInvert.value())
2746  {
2747  if ((cx >= tx1) && (cy >= ty1) && (cx <= tx2) && (cy <= ty2))
2748  {
2749  doit = true;
2750  }
2751  }
2752  else if ((cx < tx1) || (cy < ty1) || (cx > tx2) || (cy > ty2))
2753  {
2754  doit = true;
2755  }
2756  if (doit)
2757  {
2758  if (random(100)<cfg_BeetleBankChance.value())
2759  {
2760  if (BeetleBankPossible( m_elems[ i ], a_tole) ) BBs++;
2761  }
2762  }
2763  }
2764  }
2765  char str[25];
2766  sprintf(str,"%d",BBs);
2767  g_msg->Warn( WARN_MSG, "Landscape::AddBeetleBanks(): BeetleBanks successfully added:", str );
2768 }
CfgInt cfg_BeetleBankMinY("BBANK_MINY", CFG_CUSTOM, 0)
CfgInt cfg_BeetleBankMinX("BBANK_MINX", CFG_CUSTOM, 0)
CfgInt cfg_BeetleBankMaxY("BBANK_MAXY", CFG_CUSTOM, 100000)
static CfgInt cfg_BeetleBankChance("BBANK_CHANCE", CFG_CUSTOM, 100)
CfgInt cfg_BeetleBankMaxX("BBANK_MAXX", CFG_CUSTOM, 100000)
CfgBool cfg_BeetleBankInvert("BBANK_INVERT", CFG_CUSTOM, false)
bool BeetleBankPossible(LE *a_field, TTypesOfLandscapeElement a_tole)
Definition: Landscape.cpp:2772
@ WARN_MSG
Definition: maperrormsg.h:38

References cfg_BeetleBankChance, cfg_BeetleBankInvert, cfg_BeetleBankMaxX, cfg_BeetleBankMaxY, cfg_BeetleBankMinX, cfg_BeetleBankMinY, g_msg, random(), tole_Field, CfgInt::value(), CfgBool::value(), MapErrorMsg::Warn(), and WARN_MSG.

◆ AddGreenElement()

void Landscape::AddGreenElement ( LE a_green)
protected

◆ AxisLoop() [1/2]

void Landscape::AxisLoop ( int  a_poly,
APoint a_cor,
int  a_axis 
)
protected

Starting at a_x,a_y each location is tested along a vector given by m_x_add & m_y_add until we step outside the polygon. a_x & a_y are modified on return.

2898  {
2903  int ap1 = a_polyindex;
2904  while (ap1 == a_polyindex)
2905  {
2906  a_cor->m_x += m_x_add[a_axis];
2907  a_cor->m_y += m_y_add[a_axis];
2908  if (a_cor->m_x >= m_width - 1) { a_cor->m_x = m_width - 1; return; }
2909  if (a_cor->m_y >= m_height - 1) { a_cor->m_y = m_height - 1; return; }
2910  if (a_cor->m_x <= 0) { a_cor->m_x = 0; return; }
2911  if (a_cor->m_y <= 0) { a_cor->m_y = 0; return; }
2912  ap1 = m_land->Get(a_cor->m_x, a_cor->m_y); // NB this returns the m_elemens index not the polyref (ChangeMapMapping has been called by here)
2913  }
2914 }
int m_y
Definition: ALMaSS_Setup.h:56
int m_x
Definition: ALMaSS_Setup.h:55
int Get(int a_x, int a_y)
Definition: rastermap.h:81

References APoint::m_x, and APoint::m_y.

◆ AxisLoop() [2/2]

void Landscape::AxisLoop ( int  a_poly,
int *  a_x,
int *  a_y,
int  a_axis 
)
protected

Starting at a_x,a_y each location is tested along a vector given by m_x_add & m_y_add until we step outside the polygon. a_x & a_y are modified on return.

2938  {
2943  int ap1 = a_polyindex;
2944  while (ap1 == a_polyindex)
2945  {
2946  *(a_x) += m_x_add[a_axis];
2947  *(a_y) += m_y_add[a_axis];
2948  // Before we try to get a polyindex from the map, check we are still on the world
2949  if (*(a_x) < 0)
2950  {
2951  return;
2952  }
2953  if (*(a_y) < 0)
2954  {
2955  return;
2956  }
2957  if (*(a_x) >= m_width)
2958  {
2959  return;
2960  }
2961  if (*(a_y) >= m_height)
2962  {
2963  return;
2964  }
2965  // OK still in the map, get the polyindex
2966  ap1 = m_land->Get((*a_x), (*a_y)); // NB this returns the m_elemens index not the polyref (ChangeMapMapping has been called by here)
2967  }
2968 }

◆ AxisLoopLtd()

void Landscape::AxisLoopLtd ( int  a_poly,
APoint a_cor,
int  a_axis,
int  a_limit 
)
protected

Starting at a_x,a_y each location is tested along a vector given by m_x_add & m_y_add until we step outside the polygon. a_x & a_y are modified on return.

2917  {
2922  int ap1 = a_polyindex;
2923  int count = 0;
2924  while (ap1 == a_polyindex && count<a_limit)
2925  {
2926  a_cor->m_x += m_x_add[a_axis];
2927  a_cor->m_y += m_y_add[a_axis];
2928  if (a_cor->m_x >= m_width - 1) { a_cor->m_x = m_width - 1; return; }
2929  if (a_cor->m_y >= m_height - 1) { a_cor->m_y = m_height - 1; return; }
2930  if (a_cor->m_x <= 0) { a_cor->m_x = 0; return; }
2931  if (a_cor->m_y <= 0) { a_cor->m_y = 0; return; }
2932  ap1 = m_land->Get(a_cor->m_x, a_cor->m_y); // NB this returns the m_elemens index not the polyref (ChangeMapMapping has been called by here)
2933  count++;
2934  }
2935 }

References APoint::m_x, and APoint::m_y.

◆ BackTranslateEleTypes()

int Landscape::BackTranslateEleTypes ( TTypesOfLandscapeElement  EleReference)
inline
1663 {
1664  return g_letype->BackTranslateEleTypes( EleReference );
1665 }

References LE_TypeClass::BackTranslateEleTypes(), and g_letype.

Referenced by Vole_Base::Set_ElemBorn().

◆ BackTranslateVegTypes()

int Landscape::BackTranslateVegTypes ( TTypesOfVegetation  VegReference)
inline
1670 {
1671  return g_letype->BackTranslateVegTypes( VegReference );
1672 }
int BackTranslateVegTypes(TTypesOfVegetation VegReference)
Definition: elements.cpp:3345

References LE_TypeClass::BackTranslateVegTypes(), and g_letype.

Referenced by Vole_Base::Set_VegBorn().

◆ BeetleBankAdd()

void Landscape::BeetleBankAdd ( int  x,
int  y,
int  angle,
int  length,
LE a_field,
TTypesOfLandscapeElement  a_tole 
)
protected
2971  {
2972  // Need to get a new number
2974  // Make the new landscape element
2975  LE * BeetleBank;
2976  switch (a_tole)
2977  {
2978  case tole_MownGrass:
2981  break;
2985  break;
2986  case tole_BeetleBank:
2987  default:
2990  }
2991  BeetleBank->SetVegPatchy(true);
2992  m_polymapping[ m_LargestPolyNumUsed ] = (int) m_elems.size();
2993  m_elems.resize( m_elems.size() + 1 );
2994  m_elems[ m_elems.size() - 1 ] = BeetleBank;
2996  // write lengthx12m to the map at alignment angle
2997  int area=0;
2998  int angle2=0;
2999  int width=cfg_BeetleBankWidth.value();
3000  if (a_angle==0) angle2=2;
3001  int start=(int)(a_length*0.1);
3002  for (int i=start; i<a_length; i++) {
3003  for (int w=0-width; w<width; w++) {
3004  int tx=w*m_x_add[angle2];
3005  int ty=w*m_y_add[angle2];
3006  m_land->Put( tx+a_x+i*m_x_add[a_angle], ty+a_y+i*m_y_add[a_angle], (int) m_elems.size() - 1 );
3007  m_land->Put( tx+a_x-i*m_x_add[a_angle], ty+a_y-i*m_y_add[a_angle], (int) m_elems.size() - 1 );
3008  area+=2;
3009  a_field->AddArea( -2.0 );
3010 
3011  }
3012  }
3013  BeetleBank->SetArea( double(area) );
3014  BeetleBank->SetValidXY( a_x+start*m_x_add[a_angle], a_y+start*m_y_add[a_angle] );
3015  BeetleBank->SetMapValid(true);
3016 
3017 }
static CfgInt cfg_BeetleBankWidth("BBANK_WIDTH", CFG_CUSTOM, 4)
Definition: elements.h:788
void SetMapValid(bool a_valid)
Definition: elements.h:227
void AddArea(double a_area_diff)
Definition: elements.h:316
void SetValidXY(int a_valid_x, int a_valid_y)
Definition: elements.h:325
vector< int > m_polymapping
Definition: landscape.h:130
void Put(int a_x, int a_y, int a_elem)
Definition: rastermap.h:57
virtual void SetVegPatchy(bool p)
Definition: elements.h:585
@ tole_PermanentSetaside
Definition: tole_declaration.h:46
@ tole_MownGrass
Definition: tole_declaration.h:74
@ tole_BeetleBank
Definition: tole_declaration.h:69
@ start
Definition: treatment.h:32

References LE::AddArea(), LE_TypeClass::BackTranslateEleTypes(), cfg_BeetleBankWidth, g_letype, m_polymapping, LE::SetALMaSSEleType(), LE::SetArea(), LE::SetMapValid(), LE::SetPoly(), LE::SetValidXY(), VegElement::SetVegPatchy(), start, tole_BeetleBank, tole_MownGrass, tole_PermanentSetaside, and CfgInt::value().

◆ BeetleBankPossible()

bool Landscape::BeetleBankPossible ( LE a_field,
TTypesOfLandscapeElement  a_tole 
)
protected

Beetle bank placement rules are:
No bank if the total bank area is going to be >=5% of the field area
No bank if the field is < 1Ha
No bank if the breadth of the field is < 100m

2772  {
2779  int farea=(int)a_field->GetArea();
2780  if (farea<10000) return false;
2781  int cx=a_field->GetCentroidX();
2782  int cy=a_field->GetCentroidY();
2783  // The centroid is the only estimate we have (and it at least should be in the field).
2784  // So start here and find the centre
2785  if (!FindFieldCenter(a_field, &cx, &cy)) return false;
2786  // now get the alignment
2787  int length=0;
2788  int alignment=FindLongestAxis(&cx, &cy, &length);
2789  // reduce length by 20%
2790  length=int(length*0.8);
2791  int area=2*length*cfg_BeetleBankWidth.value(); // 12m wide fixed size
2792  if (area>(farea*cfg_BeetleBankMaxArea.value())) return false;
2793  // Must be small engough so lets draw it
2794  BeetleBankAdd(cx, cy, alignment, length , a_field, a_tole);
2795  return true;
2796 }
static CfgFloat cfg_BeetleBankMaxArea("BBANK_MAXAREA", CFG_CUSTOM, 0.05)
double GetArea(void)
Definition: elements.h:196
virtual int GetCentroidX()
Definition: elements.h:137
virtual int GetCentroidY()
Definition: elements.h:138
bool FindFieldCenter(LE *a_field, int *x, int *y)
Definition: Landscape.cpp:2799
void BeetleBankAdd(int x, int y, int angle, int length, LE *a_field, TTypesOfLandscapeElement a_tole)
Definition: Landscape.cpp:2971
int FindLongestAxis(int *x, int *y, int *a_length)
Definition: Landscape.cpp:2851

References cfg_BeetleBankMaxArea, cfg_BeetleBankWidth, LE::GetArea(), LE::GetCentroidX(), LE::GetCentroidY(), CfgInt::value(), and CfgFloat::value().

◆ BorderAdd()

void Landscape::BorderAdd ( LE a_field,
TTypesOfLandscapeElement  a_type 
)
protected
2347  {
2348  int x = a_field->GetValidX();
2349  int y = a_field->GetValidY();
2350  if ( ( x == -1 ) || ( y == -1 ) ) {
2351  g_msg->Warn( WARN_BUG, "Landscape::BorderAdd(): Uninitialized border coordinate!", "" );
2352  exit( 1 );
2353  }
2354  LE * border = NewElement(a_type);
2355  a_field->SetBorder( border );
2356  m_polymapping[ hb_first_free_poly_num ] = (int) m_elems.size();
2357  m_elems.resize( m_elems.size() + 1 );
2358  m_elems[ m_elems.size() - 1 ] = border;
2359  border->SetPoly( hb_first_free_poly_num++ );
2360  border->SetArea( 0.0 );
2362 }
void SetBorder(LE *a_border)
Definition: elements.h:320
int GetValidX(void)
Definition: elements.h:330
int GetValidY(void)
Definition: elements.h:331
void BorderScan(LE *a_field, int a_width)
Definition: Landscape.cpp:2365
int hb_first_free_poly_num
Definition: landscape.h:274

References g_map_le_borderwidth, g_msg, LE::GetValidX(), LE::GetValidY(), m_polymapping, LE::SetArea(), LE::SetBorder(), LE::SetPoly(), CfgInt::value(), MapErrorMsg::Warn(), and WARN_BUG.

◆ BorderNeed()

bool Landscape::BorderNeed ( TTypesOfLandscapeElement  a_letype)
protected
4529  {
4530  static char error_num[20];
4531  bool AddBorder = false;
4532  switch (a_letype) {
4533  // No border is needed toward these neighbouring element types.
4534  case tole_Hedges:
4535  case tole_HedgeBank:
4536  case tole_BeetleBank:
4537  case tole_RoadsideVerge:
4538  case tole_Marsh:
4539  case tole_RiversidePlants:
4541  case tole_OrchardBand:
4542  case tole_MownGrass:
4543  case tole_WaterBufferZone:
4544  break;
4545 
4546  case tole_IndividualTree:
4547  case tole_PlantNursery:
4548  case tole_Vildtager:
4549  case tole_WindTurbine:
4550  case tole_WoodyEnergyCrop:
4551  case tole_WoodlandMargin:
4552  case tole_Pylon:
4553  case tole_NaturalGrassDry:
4554  case tole_Railway:
4555  case tole_FieldBoundary:
4556  case tole_Scrub:
4557  case tole_Field:
4559  case tole_PermPasture:
4562  case tole_PitDisused:
4563  case tole_RiversideTrees:
4564  case tole_DeciduousForest:
4565  case tole_MixedForest:
4566  case tole_YoungForest:
4567  case tole_ConiferousForest:
4568  case tole_StoneWall:
4569  case tole_Fence:
4570  case tole_Garden:
4571  case tole_Track:
4572  case tole_SmallRoad:
4573  case tole_LargeRoad:
4574  case tole_Building:
4575  case tole_ActivePit:
4576  case tole_Pond:
4577  case tole_FishFarm:
4578  case tole_Freshwater:
4579  case tole_River:
4580  case tole_Saltwater:
4581  case tole_Coast:
4582  case tole_BareRock:
4583  case tole_Heath:
4584  case tole_Orchard:
4585  case tole_AmenityGrass:
4586  case tole_Parkland:
4587  case tole_UrbanNoVeg:
4588  case tole_UrbanVeg:
4589  case tole_UrbanPark:
4591  case tole_SandDune:
4592  case tole_Copse:
4593  case tole_NaturalGrassWet:
4594  case tole_RoadsideSlope:
4595  case tole_MetalledPath:
4596  case tole_Carpark:
4597  case tole_Churchyard:
4598  case tole_Saltmarsh:
4599  case tole_Stream:
4600  case tole_HeritageSite:
4601  AddBorder = true;
4602  break;
4603 
4604  default:
4605  sprintf(error_num, "%d", a_letype);
4606  g_msg->Warn(WARN_BUG, "Landscape::BorderNeed(): Unknown element type:", error_num);
4607  exit(1);
4608  }
4609  return AddBorder;
4610 }
@ tole_BareRock
Definition: tole_declaration.h:75
@ tole_PermPastureTussocky
Definition: tole_declaration.h:45
@ tole_Saltmarsh
Definition: tole_declaration.h:88
@ tole_WoodyEnergyCrop
Definition: tole_declaration.h:94
@ tole_Carpark
Definition: tole_declaration.h:85
@ tole_Coast
Definition: tole_declaration.h:67
@ tole_UrbanNoVeg
Definition: tole_declaration.h:78
@ tole_Stream
Definition: tole_declaration.h:89
@ tole_Saltwater
Definition: tole_declaration.h:66
@ tole_MixedForest
Definition: tole_declaration.h:53
@ tole_HeritageSite
Definition: tole_declaration.h:90
@ tole_WoodlandMargin
Definition: tole_declaration.h:98
@ tole_RoadsideSlope
Definition: tole_declaration.h:83
@ tole_River
Definition: tole_declaration.h:65
@ tole_WaterBufferZone
Definition: tole_declaration.h:108
@ tole_StoneWall
Definition: tole_declaration.h:56
@ tole_Parkland
Definition: tole_declaration.h:77
@ tole_NaturalGrassWet
Definition: tole_declaration.h:87
@ tole_NaturalGrassDry
Definition: tole_declaration.h:48
@ tole_UrbanPark
Definition: tole_declaration.h:79
@ tole_Pylon
Definition: tole_declaration.h:96
@ tole_Garden
Definition: tole_declaration.h:58
@ tole_Scrub
Definition: tole_declaration.h:42
@ tole_Fence
Definition: tole_declaration.h:57
@ tole_Copse
Definition: tole_declaration.h:82
@ tole_PermPasture
Definition: tole_declaration.h:47
@ tole_Track
Definition: tole_declaration.h:59
@ tole_Heath
Definition: tole_declaration.h:70
@ tole_PitDisused
Definition: tole_declaration.h:50
@ tole_FieldBoundary
Definition: tole_declaration.h:40
@ tole_PlantNursery
Definition: tole_declaration.h:95
@ tole_DeciduousForest
Definition: tole_declaration.h:52
@ tole_UrbanVeg
Definition: tole_declaration.h:103
@ tole_ActivePit
Definition: tole_declaration.h:63
@ tole_RiversidePlants
Definition: tole_declaration.h:49
@ tole_Building
Definition: tole_declaration.h:62
@ tole_RoadsideVerge
Definition: tole_declaration.h:38
@ tole_Vildtager
Definition: tole_declaration.h:99
@ tole_YoungForest
Definition: tole_declaration.h:55
@ tole_OrchardBand
Definition: tole_declaration.h:73
@ tole_SmallRoad
Definition: tole_declaration.h:60
@ tole_Churchyard
Definition: tole_declaration.h:86
@ tole_BuiltUpWithParkland
Definition: tole_declaration.h:80
@ tole_AmenityGrass
Definition: tole_declaration.h:76
@ tole_PermPastureLowYield
Definition: tole_declaration.h:44
@ tole_Railway
Definition: tole_declaration.h:39
@ tole_WindTurbine
Definition: tole_declaration.h:97
@ tole_ConiferousForest
Definition: tole_declaration.h:54
@ tole_SandDune
Definition: tole_declaration.h:81
@ tole_IndividualTree
Definition: tole_declaration.h:93
@ tole_RiversideTrees
Definition: tole_declaration.h:51
@ tole_LargeRoad
Definition: tole_declaration.h:61
@ tole_UnsprayedFieldMargin
Definition: tole_declaration.h:72
@ tole_MetalledPath
Definition: tole_declaration.h:84
@ tole_FishFarm
Definition: tole_declaration.h:102
@ tole_Marsh
Definition: tole_declaration.h:41

References g_msg, tole_ActivePit, tole_AmenityGrass, tole_BareRock, tole_BeetleBank, tole_Building, tole_BuiltUpWithParkland, tole_Carpark, tole_Churchyard, tole_Coast, tole_ConiferousForest, tole_Copse, tole_DeciduousForest, tole_Fence, tole_Field, tole_FieldBoundary, tole_FishFarm, tole_Freshwater, tole_Garden, tole_Heath, tole_HedgeBank, tole_Hedges, tole_HeritageSite, tole_IndividualTree, tole_LargeRoad, tole_Marsh, tole_MetalledPath, tole_MixedForest, tole_MownGrass, tole_NaturalGrassDry, tole_NaturalGrassWet, tole_Orchard, tole_OrchardBand, tole_Parkland, tole_PermanentSetaside, tole_PermPasture, tole_PermPastureLowYield, tole_PermPastureTussocky, tole_PitDisused, tole_PlantNursery, tole_Pond, tole_Pylon, tole_Railway, tole_River, tole_RiversidePlants, tole_RiversideTrees, tole_RoadsideSlope, tole_RoadsideVerge, tole_Saltmarsh, tole_Saltwater, tole_SandDune, tole_Scrub, tole_SmallRoad, tole_StoneWall, tole_Stream, tole_Track, tole_UnsprayedFieldMargin, tole_UrbanNoVeg, tole_UrbanPark, tole_UrbanVeg, tole_Vildtager, tole_WaterBufferZone, tole_WindTurbine, tole_WoodlandMargin, tole_WoodyEnergyCrop, tole_YoungForest, MapErrorMsg::Warn(), and WARN_BUG.

◆ BorderRemoval()

void Landscape::BorderRemoval ( void  )
protected
2271  {
2272  // This does not need to be efficient, just do the job
2273  for (int x=1; x<(m_width-1); x++)
2274  for (int y=1; y<(m_height-1); y++)
2275  {
2277  if ((tole==tole_FieldBoundary) || (tole==tole_HedgeBank) || (tole==tole_Hedges))
2278  {
2279  if ( SupplyElementType(x-1,y-1) == tole_Field)
2280  {
2281  // Set the x,y location to be this field
2282  int fieldindex = SupplyPolyRefIndex(x-1,y-1);
2283  m_land->Put( x, y, fieldindex );
2284 
2285  }
2286  else
2287  if ( SupplyElementType(x-1,y) == tole_Field)
2288  {
2289  // Set the x,y location to be this field
2290  int fieldindex = SupplyPolyRefIndex(x-1,y);
2291  m_land->Put( x, y, fieldindex );
2292 
2293  }
2294  else
2295  if ( SupplyElementType(x-1,y+1) == tole_Field)
2296  {
2297  // Set the x,y location to be this field
2298  int fieldindex = SupplyPolyRefIndex(x-1,y+1);
2299  m_land->Put( x, y, fieldindex );
2300 
2301  }
2302  else
2303  if ( SupplyElementType(x,y-1) == tole_Field)
2304  {
2305  // Set the x,y location to be this field
2306  int fieldindex = SupplyPolyRefIndex(x,y-1);
2307  m_land->Put( x, y, fieldindex );
2308 
2309  }
2310  else
2311  if ( SupplyElementType(x,y+1) == tole_Field)
2312  {
2313  // Set the x,y location to be this field
2314  int fieldindex = SupplyPolyRefIndex(x,y+1);
2315  m_land->Put( x, y, fieldindex );
2316 
2317  }
2318  else
2319  if ( SupplyElementType(x+1,y-1) == tole_Field)
2320  {
2321  // Set the x,y location to be this field
2322  int fieldindex = SupplyPolyRefIndex(x+1,y-1);
2323  m_land->Put( x, y, fieldindex );
2324 
2325  }
2326  else
2327  if ( SupplyElementType(x+1,y) == tole_Field)
2328  {
2329  // Set the x,y location to be this field
2330  int fieldindex = SupplyPolyRefIndex(x+1,y);
2331  m_land->Put( x, y, fieldindex );
2332 
2333  }
2334  else
2335  if ( SupplyElementType(x+1,y+1) == tole_Field)
2336  {
2337  // Set the x,y location to be this field
2338  int fieldindex = SupplyPolyRefIndex(x+1,y+1);
2339  m_land->Put( x, y, fieldindex );
2340 
2341  }
2342  }
2343  }
2344 }
int SupplyPolyRefIndex(int a_x, int a_y)
Definition: landscape.h:1493

References tole_Field, tole_FieldBoundary, tole_HedgeBank, and tole_Hedges.

◆ BorderScan()

void Landscape::BorderScan ( LE a_field,
int  a_width 
)
protected

Requires centroid calculation before calling this method. Centroids must be inside the polygon and valid.

Loop through this procedure the width of the margin times. Each time a dummy margin is added using polyref=-99 and all locations this is done are remembered. Then later all positions covered by -99 are replaced with the real polygon index.

2366 {
2370  LE * border = a_field->GetBorder(); // border is the a border object
2371  int fieldpoly = a_field->GetPoly(); // fieldpoly is the polygon number
2372  int borderpoly = border->GetPoly(); // borderpoly is the polygon number
2373  int borderindex = m_polymapping[ borderpoly ]; // borderindex is the elems index for the border
2374  int fieldindex = m_polymapping[ fieldpoly ]; // fieldindex is the elems index
2375  int test = m_land->Get(a_field->GetCentroidX(), a_field->GetCentroidY());
2376  if (test != fieldindex)
2377  {
2378  g_msg->Warn("Landscape::BorderScan - Border Scan centroid does not return correct polygon index. Index :", fieldindex);
2379  g_msg->Warn(" Returned ", test);
2380  exit(0);
2381  }
2382  int notforever = 50000;
2383  vector<APoint> listoflocs;
2388  for (int wid = 0; wid < a_width; wid++)
2389  {
2390  notforever = 50000;
2391  // These two will be modified through pointer operations in BorderStep().
2392  APoint coord(a_field->GetCentroidX(), a_field->GetCentroidY());
2393  // Find the first edge cell
2394  AxisLoop(fieldindex, &coord, random(8));
2395  while (--notforever > 0)
2396  {
2397  // Check if this position should be made into a border.
2398  if (BorderTest(fieldindex, -99, coord.m_x, coord.m_y))
2399  {
2400  // Add this pixel to the border element in the big map, but using a code for later replacement.
2401  m_land->Put(coord.m_x, coord.m_y, -99); // this puts the elems index into our map in memory
2402  listoflocs.push_back(coord);
2403  a_field->AddArea(-1.0);
2404  if (l_map_exit_on_zero_area.value() && (a_field->GetArea()<1))
2405  {
2406  char polynum[20];
2407  sprintf(polynum, "%d", a_field->GetPoly());
2408  g_msg->Warn(WARN_FILE, "Landscape::BorderScan(): Polygon reached zero area " "when adding border. Poly num: ", polynum);
2409  exit(1);
2410  }
2411  border->AddArea(1.0);
2412  border->SetMapValid(true);
2413  }
2414  // Step to next coordinate. Quit when done.
2415  if (!BorderStep(fieldindex, -99, &coord))
2416  {
2417  break;
2418  }
2419  }
2420  for (std::vector<APoint>::iterator it = listoflocs.begin(); it != listoflocs.end(); ++it)
2421  {
2422  m_land->Put((*it).m_x, (*it).m_y, borderindex);
2423  }
2424  listoflocs.clear();
2425  }
2426 }
static CfgBool l_map_exit_on_zero_area("MAP_EXIT_ON_ZERO_AREA", CFG_CUSTOM, true)
A simple class defining an x,y coordinate set.
Definition: ALMaSS_Setup.h:53
LE * GetBorder(void)
Definition: elements.h:317
int GetPoly(void)
Returns the polyref number for this polygon.
Definition: elements.h:189
bool BorderStep(int a_fieldpoly, int a_borderpoly, int *a_x, int *a_y)
Definition: Landscape.cpp:2479
void AxisLoop(int a_poly, int *a_x, int *a_y, int a_axis)
Definition: Landscape.cpp:2938
bool BorderTest(int a_fieldpoly, int a_borderpoly, int a_x, int a_y)
Definition: Landscape.cpp:2452

References LE::AddArea(), g_msg, LE::GetArea(), LE::GetBorder(), LE::GetCentroidX(), LE::GetCentroidY(), LE::GetPoly(), l_map_exit_on_zero_area, m_polymapping, APoint::m_x, APoint::m_y, random(), LE::SetMapValid(), CfgBool::value(), MapErrorMsg::Warn(), and WARN_FILE.

◆ BorderStep() [1/2]

bool Landscape::BorderStep ( int  a_fieldpoly,
int  a_borderpoly,
APoint a_coord 
)
protected
2537  {
2538  int index;
2539  int x_add[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
2540  int y_add[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
2541  int width = m_land->MapWidth();
2542  int height = m_land->MapHeight();
2543  int i = 7, counter = 8;
2544  bool running = true;
2545  // First scan for another pixel that belongs to this field.
2546  while (running)
2547  {
2548  if (!((a_coord->m_x) + x_add[i] >= width) && !((a_coord->m_x) + x_add[i] < 0) && !((a_coord->m_y) + y_add[i] >= height) && !((a_coord->m_y) + y_add[i] < 0))
2549  {
2550  index = m_land->Get((a_coord->m_x) + x_add[i], (a_coord->m_y) + y_add[i]);
2551  if (index == a_fieldindex)
2552  {
2553  // Found the first field pixel while scanning around always
2554  // in the same direction.
2555  running = false;
2556  }
2557  }
2558  if (--i < 0) {
2559  // Didn't find any of our pixels. We are in a blind alley. Exit
2560  // gracefully.
2561  return false; // Signal done scanning this field.
2562  }
2563  }
2564 
2565  // Now scan around from our present facing direction and find the border
2566  // (if any).
2567  while (--counter)
2568  {
2569  if (!((a_coord->m_x) + x_add[i] >= width) && !((a_coord->m_x) + x_add[i] < 0) && !((a_coord->m_y) + y_add[i] >= height) && !((a_coord->m_y) + y_add[i] < 0))
2570  {
2571  index = m_land->Get((a_coord->m_x) + x_add[i], (a_coord->m_y) + y_add[i]);
2572  if (index == a_fieldindex)
2573  {
2574  if (--i < 0) i = 7;
2575  continue;
2576  }
2577  }
2578 
2579  // Aha! This pixel is not ours. Step one step in the
2580  // opposite(!) direction. If that pixel is ours, then
2581  // modify hotspot coordinates and exit.
2582  if (++i > 7) i = 0;
2583  if (!((a_coord->m_x) + x_add[i] + 1 > width) && !((a_coord->m_x) + x_add[i] < 0) && !((a_coord->m_y) + y_add[i] + 1 > height) &&
2584  !((a_coord->m_y) + y_add[i] < 0) && (m_land->Get((a_coord->m_x) + x_add[i], (a_coord->m_y) + y_add[i]) == a_fieldindex))
2585  {
2586  (a_coord->m_x) += x_add[i];
2587  (a_coord->m_y) += y_add[i];
2588  return true;
2589  }
2590  }
2591  return false;
2592 }

References APoint::m_x, and APoint::m_y.

◆ BorderStep() [2/2]

bool Landscape::BorderStep ( int  a_fieldpoly,
int  a_borderpoly,
int *  a_x,
int *  a_y 
)
protected
2479  {
2480  int index;
2481  int x_add[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
2482  int y_add[8] = { 0, -1, -1, -1, 0, 1, 1, 1 };
2483  int width = m_land->MapWidth();
2484  int height = m_land->MapHeight();
2485  int i = 7, counter = 8;
2486  bool running = true;
2487  // First scan for another pixel that belongs to this field.
2488  while (running)
2489  {
2490  if (!((*a_x) + x_add[i] >= width) && !((*a_x) + x_add[i] < 0) && !((*a_y) + y_add[i] >= height) && !((*a_y) + y_add[i] < 0))
2491  {
2492  index = m_land->Get((*a_x) + x_add[i], (*a_y) + y_add[i]);
2493  if (index == a_fieldindex)
2494  {
2495  // Found the first field pixel while scanning around always
2496  // in the same direction.
2497  running = false;
2498  }
2499  }
2500  if (--i < 0) {
2501  // Didn't find any of our pixels. We are in a blind alley. Exit
2502  // gracefully.
2503  return false; // Signal done scanning this field.
2504  }
2505  }
2506 
2507  // Now scan around from our present facing direction and find the border
2508  // (if any).
2509  while (--counter)
2510  {
2511  if (!((*a_x) + x_add[i] >= width) && !((*a_x) + x_add[i] < 0) && !((*a_y) + y_add[i] >= height) && !((*a_y) + y_add[i] < 0))
2512  {
2513  index = m_land->Get((*a_x) + x_add[i], (*a_y) + y_add[i]);
2514  if (index == a_fieldindex)
2515  {
2516  if (--i < 0) i = 7;
2517  continue;
2518  }
2519  }
2520 
2521  // Aha! This pixel is not ours. Step one step in the
2522  // opposite(!) direction. If that pixel is ours, then
2523  // modify hotspot coordinates and exit.
2524  if (++i > 7) i = 0;
2525  if (!((*a_x) + x_add[i] + 1 > width) && !((*a_x) + x_add[i] < 0) && !((*a_y) + y_add[i] + 1 > height) &&
2526  !((*a_y) + y_add[i] < 0) && (m_land->Get((*a_x) + x_add[i], (*a_y) + y_add[i]) == a_fieldindex))
2527  {
2528  (*a_x) += x_add[i];
2529  (*a_y) += y_add[i];
2530  return true;
2531  }
2532  }
2533  return false;
2534 }

◆ BorderTest()

bool Landscape::BorderTest ( int  a_fieldpoly,
int  a_borderpoly,
int  a_x,
int  a_y 
)
protected
2453 {
2454  int index;
2455  int x_add[ 8 ] = { 1, 1, 0, -1, -1, -1, 0, 1 };
2456  int y_add[ 8 ] = { 0, -1, -1, -1, 0, 1, 1, 1 };
2457  int width = m_land->MapWidth();
2458  int height = m_land->MapHeight();
2459  // Scan anti-clockwise from center pixel coordinate.
2460  for ( unsigned int i = 0; i < 8; i++ ) {
2461  if ( ( a_x + x_add[ i ] >= width ) || ( a_x + x_add[ i ] < 0 ) || ( a_y + y_add[ i ] >= height )
2462  || ( a_y + y_add[ i ] < 0 ) ) {
2463  return true;
2464  }
2465  //continue;
2466  index = m_land->Get( a_x + x_add[ i ], a_y + y_add[ i ] );
2467  if ( ( index != a_fieldindex ) && ( index != a_borderindex ) )
2468  {
2469  return true;
2470  // Test removed 1/07/2014 CJT
2471  //if ( BorderNeed( m_elems[ index ]->GetElementType() ) ) return true;
2472  //else return false;
2473  }
2474  }
2475  return false;
2476 }

◆ BuildingDesignationCalc()

void Landscape::BuildingDesignationCalc ( )

used to calculate whether a building is rural or town - for rodenticide use

Runs through all elements and identifies the ones where rodenticide bait may be placed. If it is a building then we count the number of buildings near to it and designate it town if there are more than cfg_mintownbuildingnumber.

3288 {
3293  cout << "In BuildingDesignationCalc" << endl;
3294  for (int p = 0; p< (int)m_elems.size(); p++)
3295  {
3296  TTypesOfLandscapeElement tole = m_elems[p]->GetElementType();
3297  if ( tole == tole_Building)
3298  {
3299  int cx = m_elems[p]->GetCentroidX();
3300  int cy = m_elems[p]->GetCentroidY();
3301  int near = 0;
3302  for (int j = 0; j< (int)m_elems.size(); j++)
3303  {
3304  if (m_elems[j]->GetElementType() == tole_Building)
3305  {
3306  int nx = m_elems[j]->GetCentroidX();
3307  int ny = m_elems[j]->GetCentroidY();
3308  int dx =abs(cx-nx);
3309  int dy =abs(cy-ny);
3310  if ((dx < cfg_mintownbuildingdistance.value()) && (dy < cfg_mintownbuildingdistance.value())) near++;
3311  if (near > cfg_mintownbuildingdistance.value()) break;
3312  }
3313  }
3314  if (near <= cfg_mintownbuildingnumber.value()) m_elems[p]->SetCountryDesignation(1); // Not enough buildings close by, so it is a country building
3315  else m_elems[p]->SetCountryDesignation(0);
3316  }
3317  else if (tole == tole_YoungForest)
3318  {
3319  m_elems[p]->SetCountryDesignation(2);
3320  }
3321  else if ((tole == tole_DeciduousForest) || ( tole == tole_MixedForest) || ( tole == tole_ConiferousForest ) ) m_elems[p]->SetCountryDesignation(3);
3322 
3323  }
3324 }
static CfgInt cfg_mintownbuildingdistance("MAP_MINTOWNBUILDINGDISTANCE", CFG_CUSTOM, 100)
static CfgInt cfg_mintownbuildingnumber("MAP_MINTOWNBUILDINGNUMBER", CFG_CUSTOM, 6)

References cfg_mintownbuildingdistance, cfg_mintownbuildingnumber, tole_Building, tole_ConiferousForest, tole_DeciduousForest, tole_MixedForest, tole_YoungForest, and CfgInt::value().

◆ CalculateCentroids()

void Landscape::CalculateCentroids ( void  )

Finds a location inside each polygon as a roughly calculated centre point. The point will be within the polygon. This also uses the stored Max/Min coordinates for each polygon that form a rectangle around it.

3041 {
3047  cout << "In Centroid Calculations" << endl;
3048  // For each polygon
3049  for (int p = 0; p< (int)m_elems.size(); p++)
3050  {
3051  // Calcuate the actual centre
3052  int x1 = m_elems[p]->GetMinX();
3053  int y1 = m_elems[p]->GetMinY();
3054  int x2 = m_elems[p]->GetMaxX();
3055  int y2 = m_elems[p]->GetMaxY();
3056 
3057  int midx = (x1 + x2) / 2;
3058  int midy = (y1 + y2) / 2;
3059  // Now from midx & midy we move outwards in concentric circles until we find a location that matches our polyref.
3060  int polyindex = p; // Change mapmapping has been called by now, so the map contains m_elems indices.
3061  CentroidSpiralOut(polyindex, midx, midy);
3062  // Now we want to be sure that we are in the middle of the polygon not on the edge. This is tricky for complex shaped polygons,
3063  // but we have a stab at it by using the FindLongestAxis method. This puts us in the centre of the longest axis in 8 directions
3064  // from this point
3065  int l;
3066  FindLongestAxis(&midx, &midy, &l);
3067  m_elems[p]->SetCentroid(midx, midy);
3068  }
3070 }
void BuildingDesignationCalc()
used to calculate whether a building is rural or town - for rodenticide use
Definition: Landscape.cpp:3287
void CentroidSpiralOut(int a_polyref, int &a_x, int &a_y)
Definition: Landscape.cpp:3073

◆ CalculateOpenness()

void Landscape::CalculateOpenness ( bool  a_realcalc)

Causes openness to be calulated and stored for all polygons.

First must calculate centroid. Runs through the list of elements and any that are marsh, field, or pasture will have an openness score calculated

323 {
327  cout << "In CalculateOpenness" << endl;
328 
329  for (unsigned int i = 0; i < m_elems.size(); i++)
330  {
331  TTypesOfLandscapeElement tole = m_elems[i]->GetElementType();
332  switch (tole)
333  {
334  case tole_Field:
335  case tole_Marsh:
336  case tole_Scrub:
340  case tole_PermPasture:
343  if (a_realcalc)
344  {
345  cout << i << " ";
346  m_elems[i]->SetOpenness(CalulateFieldOpennessAllCells(i));
347  }
348  else m_elems[i]->SetOpenness(0);
349  break;
350  default:
351  m_elems[i]->SetOpenness(0);
352  break;
353  }
354  }
355  if (a_realcalc) cout << endl;
356 }
int CalulateFieldOpennessAllCells(int a_pref)
Provides a measure of the shortest distance in 360 degree, e-g- looking NE % SW before tall obstacles...
Definition: Landscape.cpp:401

References tole_Field, tole_Marsh, tole_NaturalGrassDry, tole_NaturalGrassWet, tole_PermanentSetaside, tole_PermPasture, tole_PermPastureLowYield, tole_PermPastureTussocky, and tole_Scrub.

◆ CalulateFieldOpennessAllCells()

int Landscape::CalulateFieldOpennessAllCells ( int  a_pref)

Provides a measure of the shortest distance in 360 degree, e-g- looking NE % SW before tall obstacles are encountered at both ends. Checks all field 1m2.

Starts with North West and moves round the points of the compass 180 degrees. For each point tested we want the minimum length found, but between points we are interested in the max

runs a line out and also in 180 degrees, two lines.

runs a line out and also in 180 degrees, two lines.

402 {
403  int dline;
404  int d0 = 0;
405  int minX = m_elems[a_pref]->GetMinX();
406  int minY = m_elems[a_pref]->GetMinY();
407  int maxX = m_elems[a_pref]->GetMaxX();
408  int maxY = m_elems[a_pref]->GetMaxY();
409  for (int ax = minX; ax <= maxX; ax+=10)
410  {
411  for (int ay = minY; ay <= maxY; ay+=10)
412  {
413  dline = m_maxextent; // this is the width of the landscape and will always be at least as big as the biggest return value possible
414  // Get a possible point for this field
415  int cx = ax;
416  int cy = ay;
417  if (m_land->Get(ax, ay) == a_pref)
418  {
423  double offsetx = -1;
424  double offsety = -1;
425  double dx = 1.0 / 45.0;
426  double dy = 0.0;
427  for (int deg = 0; deg<90; deg++)
428  {
430  int d1 = LineHighTest(cx, cy, offsetx, offsety);
431  int d2 = LineHighTest(cx, cy, 0 - offsetx, 0 - offsety);
432  int d = d1;
433  if (d1 > d2) d = d2;
434  if (dline > d) dline = d; // get the minimum
435  offsetx = offsetx + dx;
436  offsety = offsety + dy;
437  }
438  offsetx = 1;
439  offsety = 1;
440  dy = 0 - dx;
441  dx = 0;
442  for (int deg = 0; deg<90; deg++)
443  {
445  int d1 = LineHighTest(cx, cy, offsetx, offsety);
446  int d2 = LineHighTest(cx, cy, 0 - offsetx, 0 - offsety);
447  int d = d1;
448  if (d1 > d2) d = d2;
449  if (dline > d) dline = d;
450  offsetx = offsetx + dx;
451  offsety = offsety + dy;
452  }
453  if (dline > d0) d0 = dline; // Get the maximum. Here we might also want to do something like create statistics from the range of dline
454  }
455  }
456  }
457  return d0;
458 }
int LineHighTest(int a_cx, int a_cy, double a_offsetx, double a_offsety)
Provides a measure of the shortest distance in using a vector from a_cx,a_cy unitl tall obstacles are...
Definition: Landscape.cpp:461

◆ CalulateFieldOpennessCentroid()

int Landscape::CalulateFieldOpennessCentroid ( int  a_pref)

Provides a measure of the shortest distance in 360 degree, e-g- looking NE % SW before tall obstacles are encountered at both ends. Searches from centroid.

Starts with North West and moves round the points of the compass 180 degrees.

runs a line out and also in 180 degrees, two lines.

runs a line out and also in 180 degrees, two lines.

360 {
361  // Get the centre point for this field
362  int d0 = m_maxextent; // this is the width of the landscape and will always be at least as big as the biggest return value possible
363  int cx = m_elems[a_pref]->GetCentroidX();
364  int cy = m_elems[a_pref]->GetCentroidY();
365 
367  double offsetx = -1;
368  double offsety = -1;
369  double dx = 1.0 / 45.0;
370  double dy = 0.0;
371  for (int deg = 0; deg<90; deg++)
372  {
374  int d1 = LineHighTest(cx, cy, offsetx, offsety);
375  int d2 = LineHighTest(cx, cy, 0 - offsetx, 0 - offsety);
376  int d = d1;
377  if (d1 > d2) d = d2;
378  if (d0 > d) d0 = d;
379  offsetx = offsetx + dx;
380  offsety = offsety + dy;
381  }
382  offsetx = 1;
383  offsety = 1;
384  dy = 0 - dx;
385  dx = 0;
386  for (int deg = 0; deg<90; deg++)
387  {
389  int d1 = LineHighTest(cx, cy, offsetx, offsety);
390  int d2 = LineHighTest(cx, cy, 0 - offsetx, 0 - offsety);
391  int d = d1;
392  if (d1 > d2) d = d2;
393  if (d0 > d) d0 = d;
394  offsetx = offsetx + dx;
395  offsety = offsety + dy;
396  }
397  return d0;
398 }

◆ CentroidSpiralOut()

void Landscape::CentroidSpiralOut ( int  a_polyref,
int &  a_x,
int &  a_y 
)
3074 {
3075  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref) return; // Found it so return
3076  // Otherwise its not found so we need to start to spiral out
3077  int loop = 1;
3078  int sx = a_x;
3079  int sy = a_y;
3080  do {
3081  a_y = sy - loop;
3082  for (int i = 0 - loop; i <= loop; i++)
3083  {
3084  a_x = sx + i;
3085  CorrectCoords(a_x, a_y);
3086  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
3087  return; // Found it so return
3088  }
3089  a_y = sy + loop;
3090  for (int i = 0 - loop; i <= loop; i++)
3091  {
3092  a_x = sx + i;
3093  CorrectCoords(a_x, a_y);
3094  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
3095  return; // Found it so return
3096  }
3097  a_x = sx + loop;
3098  for (int j = 0 - (loop - 1); j< loop; j++)
3099  {
3100  a_y = sy + j;
3101  CorrectCoords(a_x, a_y);
3102  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
3103  return; // Found it so return
3104  }
3105  a_x = sx - loop;
3106  for (int j = 0 - (loop - 1); j< loop; j++)
3107  {
3108  a_y = sy + j;
3109  CorrectCoords(a_x, a_y);
3110  if (SupplyPolyRefIndex(a_x, a_y) == a_polyref)
3111  return; // Found it so return
3112  }
3113  loop++;
3114  } while (loop<m_minmaxextent); // This stopping rule should hopefully not be needed, it is set very high.
3115  g_msg->Warn("Landscape::CentroidSpiralOut: Failure of centroid main loop. Looking for polygon index ",a_polyref);
3116  a_x = m_elems[a_polyref]->GetMinX();
3117  a_y = m_elems[a_polyref]->GetMinY();
3118 }
void CorrectCoords(int &x, int &y)
Function to prevent wrap around errors with co-ordinates using x/y pair.
Definition: landscape.h:1535

References g_msg, and MapErrorMsg::Warn().

◆ ChangeMapMapping()

void Landscape::ChangeMapMapping ( void  )
protected

Our map is an array of polygon indentifiers, where we really want to know the associated landscape element of a X-Y coordinate pair.
Changing this to m_elems[] indices will save us one redirection when inquiring information from the landscape, and only costs us the fixed translation step performed here at startup.

2130  {
2136  cout << "In Change Map Mapping" << endl;
2137  int mapwidth = m_land->MapWidth();
2138  int mapheight = m_land->MapHeight();
2139  int pest_map_width = mapwidth >> PEST_GRIDSIZE_POW2;
2140  if ( mapwidth & ( PEST_GRIDSIZE - 1 ) ) pest_map_width++;
2141  int oldindex = -1;
2142  for ( int x = 0; x < mapwidth; x++ )
2143  {
2144  for ( int y = 0; y < mapheight; y++ )
2145  {
2146  int polynum = m_land->Get( x, y ); // the polyref e.g. = 1, m_polymapping[ polynum ] = 0
2147  m_elems[ m_polymapping[ polynum ]]->SetMapIndex( m_polymapping[ polynum ] ); // Here we set index in the map to the index in elements, i.e. 0
2148  m_elems[ m_polymapping[ polynum ]]->SetMapValid( true );
2149  // Do the translation.
2150  m_land->Put( x, y, m_polymapping[ polynum ] ); // and now we write this to the map, i.e. 0
2151  // This coordinate is now valid. Throw these coordinates into
2152  // the associated landscape element.
2153  int index = m_polymapping[ SupplyPolyRef( x, y ) ];
2154  if ( index != oldindex )
2155  {
2156  m_elems[ index ]->SetValidXY( x, y );
2157  int l_x = x >> PEST_GRIDSIZE_POW2;
2158  int l_y = y >> PEST_GRIDSIZE_POW2;
2159  int pref = l_y * pest_map_width + l_x;
2160  m_elems[ index ]->SetPesticideCell( pref );
2161  oldindex = index;
2162  }
2163  }
2164  }
2165  RebuildPolyMapping();
2166 /*
2167 // Check that all of the polygons are mentioned in the map.
2168  if ( l_map_check_polygon_xref.value() )
2169  {
2170  for ( unsigned int i = 0; i < m_elems.size(); i++ )
2171  {
2172  if ( !m_elems[ i ]->GetMapValid() ) {
2173  char poly[ 20 ];
2174  sprintf( poly, "%d", m_elems[ i ]->GetPoly() );
2175  g_msg->Warn( WARN_FILE, "Landscape::ChangeMapMapping(): ""Polygon number referenced but not in map file: ", poly );
2176  exit( 1 );
2177  }
2178  }
2179  }
2180 */
2181 }
void RebuildPolyMapping()
Definition: landscape.h:213
int SupplyPolyRef(int a_x, int a_y)
Definition: landscape.h:1488
#define PEST_GRIDSIZE_POW2
Definition: pesticide.h:39
#define PEST_GRIDSIZE
Definition: pesticide.h:40

References m_polymapping, PEST_GRIDSIZE, and PEST_GRIDSIZE_POW2.

◆ CheckForPesticideRecord()

void Landscape::CheckForPesticideRecord ( LE a_field,
TTypesOfPesticideCategory  a_pcide 
)

Check if needed and record pesticide application.

670 {
672  {
673  if (cfg_pesticidemaptype.value() == false)
674  {
675  m_PesticideMap->Spray(a_field, a_pcide);
676  }
677  else
678  {
679  if (a_pcide == testpesticide) m_PesticideMap->Spray(a_field, insecticide);
680  }
681  }
682 }
void Spray(LE *a_element_sprayed, TTypesOfPesticideCategory a_type)
Definition: pesticide.cpp:854
@ insecticide
Definition: landscape.h:63
@ testpesticide
Definition: landscape.h:63

References cfg_pesticidemapon, cfg_pesticidemaptype, insecticide, testpesticide, and CfgBool::value().

Referenced by Farm::FungicideTreat(), OptimisingFarm::FungicideTreat(), Farm::HerbicideTreat(), OptimisingFarm::HerbicideTreat(), Farm::InsecticideTreat(), OptimisingFarm::InsecticideTreat(), Farm::Molluscicide(), and Farm::ProductApplication().

◆ CIPELandscapeMaker()

bool Landscape::CIPELandscapeMaker ( )
protected

◆ ConsolidatePolys()

void Landscape::ConsolidatePolys ( void  )
protected

Runs through the map checking each cell for polygon type. If it is in our replace list then it re-written as the first instance of that polygon type encountered. All subsequent instances of that type are then deleted.
replaceList contains the types of all tole types with no behaviour that can be consolidated. This list needs to be kept up-to-date.

1330 {
1336  const int TypesToReplace = 16;
1337  TTypesOfLandscapeElement replaceList[TypesToReplace] = {
1338  tole_River,
1342  tole_BareRock,
1344  tole_Carpark,
1346  tole_Coast,
1347  tole_Garden,
1352  tole_SandDune,
1354  };
1355  int foundList[TypesToReplace];
1356  cout << "Consolidating polygons with no special behaviour" << endl;
1357  for (int i = 0; i < TypesToReplace; i++) foundList[i] = -1;
1358  int mapwidth = m_land->MapWidth();
1359  int mapheight = m_land->MapHeight();
1360  for (int x = 0; x < mapwidth; x++)
1361  {
1362  for (int y = 0; y < mapheight; y++)
1363  {
1364  int ele = m_land->Get(x, y);
1365  TTypesOfLandscapeElement tole = m_elems[m_polymapping[ele]]->GetElementType();
1366  for (int t = 0; t < TypesToReplace; t++)
1367  {
1368  if (tole == replaceList[t])
1369  {
1370  // Must do something with this cell
1371  if (foundList[t] == -1) foundList[t] = ele;
1372  else
1373  {
1374  // Need to replace this cell
1375  m_land->Put(x, y, foundList[t]);
1376  }
1377  }
1378  }
1379  }
1380  }
1381  // At this point there should be many polygons that are not in the map. So we need to run the valid test.
1382  g_msg->Warn(WARN_FILE, "Landscape::ConsolidatePolys() - ""Consolidate map dump.", "");
1383 }

References g_msg, m_polymapping, tole_BareRock, tole_BuiltUpWithParkland, tole_Carpark, tole_Churchyard, tole_Coast, tole_Garden, tole_HeritageSite, tole_IndividualTree, tole_PlantNursery, tole_River, tole_RiversidePlants, tole_RiversideTrees, tole_Saltwater, tole_SandDune, tole_StoneWall, tole_UrbanNoVeg, MapErrorMsg::Warn(), and WARN_FILE.

◆ CorrectCoords()

void Landscape::CorrectCoords ( int &  x,
int &  y 
)
inline

Function to prevent wrap around errors with co-ordinates using x/y pair.

m_width10 & m_height10 are used to avoid problems with co-ordinate values that are very large. Problems will only occur if coords passed are >10x the world width or height.

1536 {
1540  x = (m_width10 + x) % m_width;
1541  y = (m_height10 + y) % m_height;
1542 }

References m_height, m_height10, m_width, and m_width10.

Referenced by Skylark_Female::CheckForFields(), Roe_Female::FEstablishRange(), Vole_Population_Manager::IsTrap(), Roe_Base::NextStep(), and Roe_Base::WalkTo().

◆ CorrectCoordsPointNoWrap()

void Landscape::CorrectCoordsPointNoWrap ( APoint a_pt)
inline

Function to prevent wrap around errors with co-ordinates using a APoint.

This just cuts off extremes of coordinate values so that the point stays in landscape. Can't use a modulus or we get wrap around, and in this case we don't want that

1556 {
1560  if (a_pt.m_x >= m_width) a_pt.m_x = m_width - 1;
1561  if (a_pt.m_y >= m_height) a_pt.m_y = m_height - 1;
1562  if (a_pt.m_x < 0) a_pt.m_x = 0;
1563  if (a_pt.m_y < 0) a_pt.m_y = 0;
1564 }

References m_height, m_width, APoint::m_x, and APoint::m_y.

Referenced by Goose_Barnacle_Base::ChooseHopLoc(), Goose_Greylag_Base::ChooseHopLoc(), and Goose_Pinkfoot_Base::ChooseHopLoc().

◆ CorrectCoordsPt()

APoint Landscape::CorrectCoordsPt ( int  x,
int  y 
)
inline

Function to prevent wrap around errors with co-ordinates using x/y pair.

m_width10 & m_height10 are used to avoid problems with co-ordinate values that are very large. Problems will only occur if coords passed are >10x the world width or height.

1545 {
1549  APoint pt;
1550  pt.m_x = (m_width10 + x) % m_width;
1551  pt.m_y = (m_height10 + y) % m_height;
1552  return pt;
1553 }

References m_height, m_height10, m_width, m_width10, APoint::m_x, and APoint::m_y.

Referenced by Hare_Female::PlaceYoung().

◆ CorrectHeight()

int Landscape::CorrectHeight ( int  y)
inline
1574 {
1575  return (m_height10+y)%m_height;
1576 }

References m_height, and m_height10.

Referenced by Roe_Base::NextStep().

◆ CorrectWidth()

int Landscape::CorrectWidth ( int  x)
inline
1568 {
1569  return (m_width10+x)%m_width;
1570 }

References m_width, and m_width10.

Referenced by Roe_Base::NextStep().

◆ CountMapSquares()

void Landscape::CountMapSquares ( void  )
protected
2040  {
2041  int mapwidth = m_land->MapWidth();
2042  int mapheight = m_land->MapHeight();
2043  for ( unsigned int i = 0; i < m_elems.size(); i++ ) {
2044  m_elems[i]->SetArea(0);
2045  m_elems[ i ]->m_squares_in_map=0;
2046  }
2047 
2048  for ( int x = 0; x < mapwidth; x++ ) {
2049  for ( int y = 0; y < mapheight; y++ ) {
2050  int l_ele = m_land->Get( x, y );
2051  m_elems[ l_ele ]->m_squares_in_map++;
2052  }
2053  }
2054 }

◆ CreatePondList()

void Landscape::CreatePondList ( )
protected

Creates a list of pond polygon refs/indexes for easy look up.

Just creates an unordered list of polyref numbers and m_elems indices for all ponds. This is for easy look-up by e.g. newts

2595 {
2597  for (unsigned int i = 0; i < m_elems.size(); i++)
2598  {
2599  if (m_elems[i]->GetElementType() == tole_Pond) {
2600  m_PondIndexList.push_back(i);
2601  m_PondRefsList.push_back(m_elems[i]->GetPoly());
2602  }
2603  }
2604 }
vector< int > m_PondRefsList
List of pond polyrefs.
Definition: landscape.h:199
vector< int > m_PondIndexList
List of pond indexes.
Definition: landscape.h:197

References tole_Pond.

◆ DegreesDump()

void Landscape::DegreesDump ( )
protected

Prints the sum of day degrees. See FarmManager::daydegrees.

1687  {
1688 
1689  ofstream ofile ("Daydegrees.txt", ios::app);
1690  //print degrees
1691  ofile << m_FarmManager->GetDD();
1692  ofile << endl;
1693  ofile.close();
1694 }
double GetDD(void)
Returnes day degrees for the period March 1st - November 1st. Used for determining yields of crops th...
Definition: farm.h:1835

◆ DumpAllSymbolsAndExit()

void Landscape::DumpAllSymbolsAndExit ( const char *  a_dumpfile)
inline
785  {
786  g_cfg->DumpAllSymbolsAndExit( a_dumpfile );
787  }
void DumpAllSymbolsAndExit(const char *a_dumpfile)
Definition: configurator.cpp:601
class Configurator * g_cfg
Definition: configurator.cpp:49

References Configurator::DumpAllSymbolsAndExit(), and g_cfg.

◆ DumpCentroids()

void Landscape::DumpCentroids ( void  )
3276 {
3277  ofstream centroidfile("PolygonCentroids.txt", ios::out);
3278  centroidfile<<"Polyref"<<'\t'<<"CX"<<'\t'<<"CY"<<'\t'<<"Type"<<'\t'<<"Area"<<'\t'<<"Country Designation"<<endl;
3279  for (int p = 0; p< (int)m_elems.size(); p++)
3280  {
3281  centroidfile<<m_elems[p]->GetPoly()<<'\t'<<m_elems[p]->GetCentroidX()<<'\t'<<m_elems[p]->GetCentroidY()<<'\t'<<m_elems[p]->GetElementType()<<'\t'<<m_elems[p]->GetArea()<<'\t'<<m_elems[p]->GetCountryDesignation()<<endl;
3282  }
3283  centroidfile.close();
3284 }

◆ DumpMap()

void Landscape::DumpMap ( const char *  a_filename)
protected
1387 {
1388  int * l_map = m_land->GetMagicP(0, 0); // Hmmm - this is a nasty way round the class data protection. Gets a pointer direct to m_map in rastermap.
1389  /* FILE * l_file;
1390  l_file = fopen(a_filename, "wb" );
1391  if ( !l_file ) {
1392  g_msg->Warn( WARN_FILE, "Landscape::DumpMap(): Unable to open file", a_filename );
1393  exit( 0 );
1394  }
1395 
1396  char * l_id = m_land->GetID();
1397 
1398 
1399  fwrite( l_id, 1, 12, l_file );
1400  fwrite( & m_width, 1, sizeof( int ), l_file );
1401  if (cfg_rectangularmaps_on.value() )
1402  {
1403  fwrite( & m_height, 1, sizeof( int ), l_file );
1404  }
1405  for ( int i = 0; i < m_width * m_height; i++ )
1406  {
1407  LE* le = m_elems[m_polymapping[l_map[i]]];
1408  int l_poly = le->GetPoly();
1409  fwrite( & l_poly, 1, sizeof( int ), l_file );
1410  }
1411  fclose( l_file );
1412  */
1413  ofstream OFile( a_filename, ios::binary);
1414  char id[12] = { "LSB2_Format" };
1415  OFile.write(id, 12);
1416  OFile.write((char*)&m_width, sizeof (int));
1417  OFile.write((char*)&m_height, sizeof (int));
1418  OFile.write((char*)l_map, m_width*m_height*sizeof (int));
1419  OFile.close();
1420 }
int * GetMagicP(int a_x, int a_y)
Definition: rastermap.h:74

◆ DumpMapGraphics()

void Landscape::DumpMapGraphics ( const char *  a_filename)
protected
3599  {
3600  unsigned int linesize = m_maxextent * 3;
3601  unsigned char * frame_buffer = (unsigned char *)malloc(sizeof(unsigned char)* linesize);
3602 
3603  if (frame_buffer == NULL) {
3604  g_msg->Warn(WARN_FILE, "Landscape::DumpMapGraphics(): Out of memory!", "");
3605  exit(1);
3606  }
3607 
3608  FILE * l_file = fopen(a_filename, "w");
3609  if (!l_file) {
3610  g_msg->Warn(WARN_FILE, "Landscape::DumpMapGraphics(): ""Unable to open file for writing: %s\n", a_filename);
3611  exit(1);
3612  }
3613 
3614  fprintf(l_file, "P6\n%d %d %d\n", m_width, m_height, 255);
3615 
3616  for (int y = 0; y < m_height; y++) {
3617  int i = 0;
3618  for (int x = 0; x < m_width; x++) {
3619  int eletype = (int)SupplyElementType(x, y);
3620  int localcolor = 16777215 / eletype;
3621 
3622  if (eletype == (int)tole_Field) {
3623  int category;
3624  double hei = SupplyVegHeight(x, y);
3625  if (hei > 50.0) category = 0; else category = (int)(200.0 - (hei * 4.0));
3626  localcolor = ((category * 65536) + 65535);
3627  }
3628 
3629  frame_buffer[i++] = (unsigned char)(localcolor & 0xff);
3630  frame_buffer[i++] = (unsigned char)((localcolor >> 8) & 0xff);
3631  frame_buffer[i++] = (unsigned char)((localcolor >> 16) & 0xff);
3632  }
3633  fwrite(frame_buffer, sizeof(unsigned char), linesize, l_file);
3634  }
3635 
3636  fclose(l_file);
3637 
3638  free(frame_buffer);
3639 }
double SupplyVegHeight(int a_polyref)
Definition: landscape.h:936

References g_msg, tole_Field, MapErrorMsg::Warn(), and WARN_FILE.

◆ DumpMapInfoByArea()

void Landscape::DumpMapInfoByArea ( const char *  a_filename,
bool  a_append,
bool  a_dump_zero_areas,
bool  a_write_veg_names 
)
3652  {
3653  FillVegAreaData();
3654  FILE * outf;
3655  if (a_append) {
3656  outf = fopen(a_filename, "a");
3657  if (!outf) {
3658  g_msg->Warn(WARN_FILE, "Landscape::DumpMapInfoByArea(): ""Unable to open file for appending", a_filename);
3659  exit(1);
3660  }
3661  }
3662  else {
3663  outf = fopen(a_filename, "w");
3664  if (!outf) {
3665  g_msg->Warn(WARN_FILE, "Landscape::DumpMapInfoByArea(): ""Unable to open file for writing", a_filename);
3666  exit(1);
3667  }
3668  }
3669 
3670  // Emit element type info.
3671  for (unsigned int i = 0; i < tov_Undefined + 1; i++) {
3672  if (i == tov_OFirstYearDanger)
3673  continue;
3674  if (!a_dump_zero_areas && l_vegtype_areas[i] < 0.5)
3675  continue;
3676 
3677  fprintf(outf, "%6ld\t%3d\t%10.0f", g_date->OldDays() + g_date->DayInYear() - 364, i, l_vegtype_areas[i]);
3678  if (a_write_veg_names)
3679  fprintf(outf, "\t%s\n", VegtypeToString((TTypesOfVegetation)i).c_str()); else
3680  fprintf(outf, "\n");
3681  }
3682 
3683  fclose(outf);
3684 }
long OldDays(void)
Definition: calendar.h:60
int DayInYear(void)
Definition: calendar.h:58
void FillVegAreaData()
Definition: Landscape.cpp:3641
std::string VegtypeToString(TTypesOfVegetation a_veg)
Definition: Landscape.cpp:4235
TTypesOfVegetation
Definition: tov_declaration.h:30
@ tov_OFirstYearDanger
Definition: tov_declaration.h:44

References Calendar::DayInYear(), g_date, g_msg, Calendar::OldDays(), tov_OFirstYearDanger, tov_Undefined, MapErrorMsg::Warn(), and WARN_FILE.

◆ DumpPublicSymbols()

void Landscape::DumpPublicSymbols ( const char *  a_dumpfile,
CfgSecureLevel  a_level 
)
inline
782  {
783  g_cfg->DumpPublicSymbols( a_dumpfile, a_level );
784  }
void DumpPublicSymbols(const char *a_dumpfile, CfgSecureLevel a_level)
Definition: configurator.cpp:590

References Configurator::DumpPublicSymbols(), and g_cfg.

◆ DumpTreatCounters()

void Landscape::DumpTreatCounters ( const char *  a_filename)
protected
3586  {
3587  FILE * l_file = fopen(a_filename, "w");
3588  if (!l_file) {
3589  g_msg->Warn(WARN_FILE, "Landscape::DumpTreatCounters(): ""Unable to open file for writing: %s\n", a_filename);
3590  exit(1);
3591  }
3592 
3593  for (int i = start; i < last_treatment; i++) {
3594  fprintf(l_file, "%3d %s %10d\n", i, EventtypeToString(i).c_str(), m_treatment_counts[i]);
3595  }
3596  fclose(l_file);
3597 }
std::string EventtypeToString(int a_event)
Definition: Landscape.cpp:3918

References g_msg, last_treatment, start, MapErrorMsg::Warn(), and WARN_FILE.

◆ DumpVegAreaData()

void Landscape::DumpVegAreaData ( int  a_day)
4680  {
4681 
4682  if (cfg_dumpvegjan.value()) {
4683  if ((a_day % 365) == 0) { // Jan 1st
4684  DumpMapInfoByArea(cfg_dumpvegjanfile.value(), true, true, true);
4685  return;
4686  }
4687  }
4688  if (cfg_dumpvegjune.value()) {
4689  if ((a_day % 365) == 152) { // 1st June
4690  DumpMapInfoByArea(cfg_dumpvegjunefile.value(), true, true, true);
4691  }
4692  }
4693 
4694 }
void DumpMapInfoByArea(const char *a_filename, bool a_append, bool a_dump_zero_areas, bool a_write_veg_names)
Definition: Landscape.cpp:3652

References cfg_dumpvegjan, cfg_dumpvegjanfile, cfg_dumpvegjune, cfg_dumpvegjunefile, CfgBool::value(), and CfgStr::value().

Referenced by RunTheSim().

◆ EventDump()

void Landscape::EventDump ( int  x,
int  y,
int  x2,
int  y2 
)
protected
1697  {
1698  FILE * vfile=fopen("EventDump.txt", "a" );
1699  if (!vfile) {
1700  g_msg->Warn( WARN_FILE, "Landscape::EventDump(): Unable to open file", "EventDump.txt" );
1701  exit( 1 );
1702  }
1703  FarmToDo event;
1704  int i = 0;
1705  int day = SupplyDayInYear();
1706  fprintf( vfile, "%d: ", day );
1707  while ( ( event = ( FarmToDo )SupplyLastTreatment( x1, y1, & i ) ) != sleep_all_day ) {
1708  fprintf( vfile, "%d ", event );
1709  }
1710  i = 0;
1711  fprintf( vfile, " - " );
1712  while ( ( event = ( FarmToDo )SupplyLastTreatment( x2, y2, & i ) ) != sleep_all_day ) {
1713  fprintf( vfile, "%d ", event );
1714  }
1715  fprintf( vfile, "\n" );
1716  fclose( vfile );
1717 }
int SupplyDayInYear(void)
Definition: landscape.h:1596
int SupplyLastTreatment(int a_polyref, int *a_index)
Definition: landscape.h:1331
FarmToDo
Definition: treatment.h:31
@ sleep_all_day
Definition: treatment.h:33

References g_msg, sleep_all_day, MapErrorMsg::Warn(), and WARN_FILE.

◆ EventDumpPesticides()

void Landscape::EventDumpPesticides ( int  x1,
int  y1 
)
protected
1720  {
1721  FILE * vfile=fopen("EventDump.txt", "a" );
1722  if (!vfile) {
1723  g_msg->Warn( WARN_FILE, "Landscape::EventDump(): Unable to open file", "EventDump.txt" );
1724  exit( 1 );
1725  }
1726  FarmToDo a_event;
1727  int i = 0;
1728  int day = this->SupplyGlobalDate();
1729  int herb = 0;
1730  int fung = 0;
1731  int ins = 0;
1732  while ( ( a_event = ( FarmToDo )SupplyLastTreatment( x1, y1, & i ) ) != sleep_all_day ) {
1733  if (a_event == herbicide_treat )
1734  {
1735  herb++;
1736  }
1737  else if (a_event == fungicide_treat ) fung++;
1738  else if (a_event == insecticide_treat) ins++;
1739  }
1740  if (herb+fung+ins >0 ) fprintf( vfile, "%d\t%d\t%d\t%d\n", day, herb, fung, ins );
1741  i = 0;
1742  fclose( vfile );
1743 }
long SupplyGlobalDate(void)
Definition: landscape.h:1621
@ herbicide_treat
Definition: treatment.h:71
@ fungicide_treat
Definition: treatment.h:73
@ insecticide_treat
Definition: treatment.h:74

References fungicide_treat, g_msg, herbicide_treat, insecticide_treat, sleep_all_day, MapErrorMsg::Warn(), and WARN_FILE.

◆ EventtypeToString()

std::string Landscape::EventtypeToString ( int  a_event)
3918  {
3919  char error_num[20];
3920 
3921  switch (a_event) {
3922  case start:
3923  return " start";
3924  case sleep_all_day:
3925  return " sleep_all_day";
3926  case autumn_plough:
3927  return " autumn_plough";
3928  case stubble_plough:
3929  return " stubble_plough";
3931  return " stubble_cultivator_heavy";
3933  return " heavy_cultivator_aggregate";
3934  case autumn_harrow:
3935  return " autumn_harrow";
3936  case preseeding_cultivator:
3937  return " preseeding_cultivator";
3939  return " preseeding_cultivator_sow";
3940  case autumn_roll:
3941  return " autumn_roll";
3942  case autumn_sow:
3943  return " autumn_sow";
3944  case winter_plough:
3945  return " winter_plough";
3946  case deep_ploughing:
3947  return " deep_ploughing";
3948  case spring_plough:
3949  return " spring_plough";
3950  case spring_harrow:
3951  return " spring_harrow";
3952  case spring_roll:
3953  return " spring_roll";
3954  case spring_sow:
3955  return " spring_sow";
3956  case spring_sow_with_ferti:
3957  return " spring_sow_with_ferti";
3958  case fp_npks:
3959  return " fp_npks";
3960  case fp_npk:
3961  return " fp_npk";
3962  case fp_pk:
3963  return " fp_pk";
3964  case fp_liquidNH3:
3965  return " fp_liquidNH3";
3966  case fp_slurry:
3967  return " fp_slurry";
3968  case fp_ammoniumsulphate:
3969  return " fp_ammoniumsulphate";
3970  case fp_manganesesulphate:
3971  return " fp_manganesesulphate";
3972  case fp_manure:
3973  return " fp_manure";
3974  case fp_greenmanure:
3975  return " fp_greenmanure";
3976  case fp_sludge:
3977  return " fp_sludge";
3978  case fp_rsm:
3979  return " fp_rsm";
3980  case fp_calcium:
3981  return " fp_calcium";
3982  case fa_npk:
3983  return " fa_npk";
3984  case fa_pk:
3985  return " fa_pk";
3986  case fa_slurry:
3987  return " fa_slurry";
3988  case fa_ammoniumsulphate:
3989  return " fa_ammoniumsulphate";
3990  case fa_manganesesulphate:
3991  return " fa_manganesesulphate";
3992  case fa_manure:
3993  return " fa_manure";
3994  case fa_greenmanure:
3995  return " fa_greenmanure";
3996  case fa_sludge:
3997  return " fa_sludge";
3998  case fa_rsm:
3999  return " fa_rsm";
4000  case fa_calcium:
4001  return " fa_calcium";
4002  case herbicide_treat:
4003  return " herbicide_treat";
4004  case growth_regulator:
4005  return " growth_regulator";
4006  case fungicide_treat:
4007  return " fungicide_treat";
4008  case insecticide_treat:
4009  return " insecticide_treat";
4010  case product_treat:
4011  return "pesticide_product_treat";
4012  case syninsecticide_treat:
4013  return " syninsecticide_treat";
4014  case molluscicide:
4015  return " molluscicide";
4016  case row_cultivation:
4017  return " row_cultivation";
4018  case strigling:
4019  return " strigling";
4020  case flammebehandling:
4021  return " flammebehandling";
4022  case hilling_up:
4023  return " hilling_up";
4024  case water:
4025  return " water";
4026  case swathing:
4027  return " swathing";
4028  case harvest:
4029  return " harvest";
4030  case cattle_out:
4031  return " cattle_out";
4032  case pigs_out:
4033  return " pigs_out";
4034  case cut_to_hay:
4035  return " cut_to_hay";
4036  case cut_to_silage:
4037  return " cut_to_silage";
4038  case straw_chopping:
4039  return " straw_chopping";
4040  case hay_turning:
4041  return " hay_turning";
4042  case hay_bailing:
4043  return " hay_bailing";
4044  case stubble_harrowing:
4045  return " stubble_harrowing";
4047  return "autumn_or_spring_plough";
4048  case burn_straw_stubble:
4049  return " burn_straw_stubble";
4050  case mow:
4051  return " mow";
4052  case cut_weeds:
4053  return " cut_weeds";
4054  case strigling_sow:
4055  return " strigling_sow";
4057  return "PesticideTrialTreatment";
4058  case trial_toxiccontrol:
4059  return " PesticideTrialToxic";
4060  case trial_control:
4061  return " PesticideTrialControl";
4062  case glyphosate:
4063  return " Glyphosate on setaside";
4064  case biocide:
4065  return " biocide";
4066  case strigling_hill:
4067  return " strigling_hill";
4068  case bed_forming:
4069  return " bed_forming";
4070  case flower_cutting:
4071  return " flower_cutting";
4072  case bulb_harvest:
4073  return " bulb_harvest";
4074  case straw_covering:
4075  return " straw_covering";
4076  case straw_removal:
4077  return " straw_removal";
4078  default:
4079  sprintf(error_num, "%d", a_event);
4080  g_msg->Warn(WARN_FILE, "Landscape::EventtypeToString(): Unknown event type:", error_num);
4081  exit(1);
4082  }
4083 }
@ burn_straw_stubble
Definition: treatment.h:92
@ autumn_harrow
Definition: treatment.h:37
@ swathing
Definition: treatment.h:81
@ fa_pk
Definition: treatment.h:62
@ winter_plough
Definition: treatment.h:42
@ strigling
Definition: treatment.h:77
@ straw_removal
Definition: treatment.h:112
@ fp_npks
Definition: treatment.h:48
@ glyphosate
Definition: treatment.h:102
@ fa_sludge
Definition: treatment.h:68
@ fp_liquidNH3
Definition: treatment.h:51
@ spring_roll
Definition: treatment.h:46
@ fa_greenmanure
Definition: treatment.h:67
@ spring_plough
Definition: treatment.h:44
@ fa_rsm
Definition: treatment.h:69
@ molluscicide
Definition: treatment.h:75
@ syninsecticide_treat
Definition: treatment.h:99
@ hay_turning
Definition: treatment.h:88
@ fa_manganesesulphate
Definition: treatment.h:64
@ autumn_roll
Definition: treatment.h:38
@ fp_manure
Definition: treatment.h:55
@ bed_forming
Definition: treatment.h:106
@ deep_ploughing
Definition: treatment.h:43
@ pigs_out
Definition: treatment.h:84
@ fa_npk
Definition: treatment.h:61
@ row_cultivation
Definition: treatment.h:76
@ heavy_cultivator_aggregate
Definition: treatment.h:108
@ spring_sow
Definition: treatment.h:47
@ fp_manganesesulphate
Definition: treatment.h:53
@ harvest
Definition: treatment.h:82
@ biocide
Definition: treatment.h:104
@ cut_to_silage
Definition: treatment.h:86
@ mow
Definition: treatment.h:93
@ preseeding_cultivator
Definition: treatment.h:39
@ fa_ammoniumsulphate
Definition: treatment.h:65
@ autumn_plough
Definition: treatment.h:34
@ straw_chopping
Definition: treatment.h:87
@ fa_manure
Definition: treatment.h:66
@ fp_greenmanure
Definition: treatment.h:56
@ fa_slurry
Definition: treatment.h:63
@ preseeding_cultivator_sow
Definition: treatment.h:40
@ product_treat
Definition: treatment.h:101
@ stubble_harrowing
Definition: treatment.h:90
@ hilling_up
Definition: treatment.h:79
@ straw_covering
Definition: treatment.h:111
@ growth_regulator
Definition: treatment.h:72
@ fp_ammoniumsulphate
Definition: treatment.h:54
@ trial_control
Definition: treatment.h:98
@ fp_rsm
Definition: treatment.h:58
@ stubble_cultivator_heavy
Definition: treatment.h:36
@ trial_insecticidetreat
Definition: treatment.h:96
@ cut_to_hay
Definition: treatment.h:85
@ cut_weeds
Definition: treatment.h:94
@ bulb_harvest
Definition: treatment.h:110
@ spring_sow_with_ferti
Definition: treatment.h:103
@ strigling_hill
Definition: treatment.h:105
@ fp_sludge
Definition: treatment.h:57
@ autumn_sow
Definition: treatment.h:41
@ fa_calcium
Definition: treatment.h:70
@ fp_npk
Definition: treatment.h:49
@ fp_pk
Definition: treatment.h:50
@ flammebehandling
Definition: treatment.h:78
@ trial_toxiccontrol
Definition: treatment.h:97
@ hay_bailing
Definition: treatment.h:89
@ spring_harrow
Definition: treatment.h:45
@ strigling_sow
Definition: treatment.h:95
@ stubble_plough
Definition: treatment.h:35
@ cattle_out
Definition: treatment.h:83
@ flower_cutting
Definition: treatment.h:109
@ fp_slurry
Definition: treatment.h:52
@ water
Definition: treatment.h:80
@ fp_calcium
Definition: treatment.h:59
@ autumn_or_spring_plough
Definition: treatment.h:91

References autumn_harrow, autumn_or_spring_plough, autumn_plough, autumn_roll, autumn_sow, bed_forming, biocide, bulb_harvest, burn_straw_stubble, cattle_out, cut_to_hay, cut_to_silage, cut_weeds, deep_ploughing, fa_ammoniumsulphate, fa_calcium, fa_greenmanure, fa_manganesesulphate, fa_manure, fa_npk, fa_pk, fa_rsm, fa_sludge, fa_slurry, flammebehandling, flower_cutting, fp_ammoniumsulphate, fp_calcium, fp_greenmanure, fp_liquidNH3, fp_manganesesulphate, fp_manure, fp_npk, fp_npks, fp_pk, fp_rsm, fp_sludge, fp_slurry, fungicide_treat, g_msg, glyphosate, growth_regulator, harvest, hay_bailing, hay_turning, heavy_cultivator_aggregate, herbicide_treat, hilling_up, insecticide_treat, molluscicide, mow, pigs_out, preseeding_cultivator, preseeding_cultivator_sow, product_treat, row_cultivation, sleep_all_day, spring_harrow, spring_plough, spring_roll, spring_sow, spring_sow_with_ferti, start, straw_chopping, straw_covering, straw_removal, strigling, strigling_hill, strigling_sow, stubble_cultivator_heavy, stubble_harrowing, stubble_plough, swathing, syninsecticide_treat, trial_control, trial_insecticidetreat, trial_toxiccontrol, MapErrorMsg::Warn(), WARN_FILE, water, and winter_plough.

Referenced by Hare_Infant::OnFarmEvent(), Hare_Young::OnFarmEvent(), Partridge_Clutch::OnFarmEvent(), Partridge_Chick::OnFarmEvent(), Partridge_Chick2::OnFarmEvent(), Partridge_Male::OnFarmEvent(), Partridge_Female::OnFarmEvent(), Skylark_Clutch::OnFarmEvent(), Skylark_Nestling::OnFarmEvent(), Skylark_PreFledgeling::OnFarmEvent(), Skylark_Female::OnFarmEvent(), Skylark_Male::OnFarmEvent(), Vole_JuvenileMale::OnFarmEvent(), and Vole_JuvenileFemale::OnFarmEvent().

◆ FillVegAreaData()

void Landscape::FillVegAreaData ( )
3641  {
3642  for (unsigned int i = 0; i < (tov_Undefined + 1); i++) {
3643  l_vegtype_areas[i] = 0.0;
3644  }
3645 
3646  // Sum up statistics on element type.
3647  for (unsigned int i = 0; i < m_elems.size(); i++) {
3648  l_vegtype_areas[m_elems[i]->GetVegType()] += m_elems[i]->GetArea();
3649  }
3650 }

References tov_Undefined.

◆ FindFieldCenter()

bool Landscape::FindFieldCenter ( LE a_field,
int *  x,
int *  y 
)
protected
2799  {
2800  // Start at x,y
2801  // works by selecting the point that is a mean of the co-ords of the centers of 4 axes from this point that are in the field.
2802  // Then do it again, and again until we don't move more than 1m or we have tried too many times
2803  int ourpoly=SupplyPolyRef(*(x),*(y));
2804  if (ourpoly!=a_field->GetPoly()) return false;
2805  int centers[2][8];
2806  int tries=0;
2807  int diff=999;
2808  int x1=*(x);
2809  int y1=*(y);
2810  int centreX=x1;
2811  int centreY=y1;
2812  // NB we might escape without bounds checking here because the polygon number does not wrap round - will only ever be a problem if we go SimX+1,SimY+1
2813  while ((diff>1) & (tries++<100)) {
2814  for (unsigned v=0; v<4; v++) {
2815  x1=centreX;
2816  y1=centreY;
2817  AxisLoop(ourpoly, &x1, &y1, v);
2818  centers[0][v]=x1-m_x_add[v];
2819  centers[1][v]=y1-m_y_add[v];
2820  x1=centreX;
2821  y1=centreY;
2822  AxisLoop(ourpoly, &x1, &y1, v+4);
2823  centers[0][v+4]=x1-m_x_add[v+4];
2824  centers[1][v+4]=y1-m_y_add[v+4];
2825 // centreX+=((centers[0][v]+x1-m_x_add[v+4])/2);
2826 // centreY+=((centers[1][v]+y1-m_y_add[v+4])/2);
2827  }
2828  int oldx=centreX;
2829  int oldy=centreY;
2830  centreX=0;
2831  centreY=0;
2832  for (int h=0; h<8; h++) {
2833  centreX+=centers[0][h];
2834  centreY+=centers[1][h];
2835  }
2836  centreX/=8;
2837  centreY/=8;
2838  diff=abs(oldx-centreX)+abs(oldy-centreY);
2839  }
2840  *(x)=centreX;
2841  *(y)=centreY;
2842  int tourpoly=SupplyPolyRef(*(x),*(y));
2843  if (tourpoly!=ourpoly) {
2844  return false; // can happen eg if there is a pond in the middle of the field
2845  }
2846 
2847  return true;
2848 }

References LE::GetPoly().

◆ FindLongestAxis()

int Landscape::FindLongestAxis ( int *  x,
int *  y,
int *  a_length 
)
protected
2852 {
2853  int ourpoly=SupplyPolyRef(*(a_x),*(a_y));
2854  int dist[4];
2855  int distx[8];
2856  int disty[8];
2857  int found = -1;
2858  *(a_length) = 0;
2859  int dx[8];
2860  int dy[8];
2861  int fx[8];
2862  int fy[8];
2863  for (unsigned v=0; v<8; v++)
2864  {
2865  int x1=*(a_x);
2866  int y1=*(a_y);
2867  AxisLoop(ourpoly, &x1, &y1, v);
2868  x1 -= m_x_add[v];
2869  y1 -= m_y_add[v];
2870  dx[v] = abs(*(a_x)-x1);
2871  dy[v] = abs(*(a_y)-y1);
2872  fx[v] = x1;
2873  fy[v] = y1;
2874  distx[v] = dx[v];
2875  disty[v] = dy[v];
2876  }
2877  for (int di = 0; di < 4; di++)
2878  {
2879  int ddx = distx[di] + distx[di + 4];
2880  int ddy = disty[di] + disty[di + 4];
2881  if (ddx == 0) dist[di] = ddy; else dist[di] = ddx;
2882  if (dist[di] > *(a_length))
2883  {
2884  found = di;
2885  *(a_length) = dist[di];
2886  }
2887  }
2888  if (found == -1) return 0;
2889  // Now need to find the middle of the axis.
2890  int l = (*(a_length) / 2);
2891  if (fx[found] > fx[found + 4]) *(a_x) = fx[found + 4] + m_x_add[found] * l; else *(a_x) = fx[found + 4] - m_x_add[found + 4] * l;
2892  if (fy[found] > fy[found + 4]) *(a_y) = fy[found + 4] + m_y_add[found] * l; else *(a_y) = fy[found + 4] - m_y_add[found + 4] * l;
2893 
2894  return found;
2895 }

◆ FindValidXY()

bool Landscape::FindValidXY ( int  a_field,
int &  a_x,
int &  a_y 
)
protected
2688  {
2689  // From a hopefully sensible starting point this method scans in the
2690  // 8 directions to find a good valid x and y matching a_field
2691  int x_add[ 8 ] = { 1, 1, 0, -1, -1, -1, 0, 1 };
2692  int y_add[ 8 ] = { 0, -1, -1, -1, 0, 1, 1, 1 };
2693  int index;
2694  int nx, ny;
2695  int width = m_land->MapWidth();
2696  int height = m_land->MapHeight();
2697  // Assume it has to within 100m
2698  for ( int i = 0; i < 100; i++ ) {
2699  for ( int l = 0; l < 8; l++ ) {
2700  nx = a_x + x_add[ l ] * i;
2701  ny = a_y + y_add[ l ] * i;
2702  if ( ( nx < width ) && ( nx >= 0 ) && ( ny < height ) && ( ny >= 0 ) ) {
2703  index = m_land->Get( nx, ny );
2704  if ( index == a_field ) {
2705  a_x = a_x + x_add[ l ] * i;
2706  a_y = a_y + y_add[ l ] * i;
2707  return true;
2708  }
2709  }
2710  }
2711  }
2712  return false;
2713 }

◆ ForceArea()

void Landscape::ForceArea ( void  )
protected
2072  {
2073  int l_area_sum = 0;
2074 
2075  for ( unsigned int i = 0; i < m_elems.size(); i++ ) {
2076  m_elems[ i ]->SetArea( ( double )m_elems[ i ]->m_squares_in_map );
2077  if ( m_elems[ i ]->m_squares_in_map > 0 ) {
2078  m_elems[ i ]->SetMapValid( true );
2079  l_area_sum += m_elems[ i ]->m_squares_in_map;
2080  }
2081  }
2082 
2083  if ( l_area_sum != m_width * m_height ) {
2084  g_msg->Warn( WARN_BUG, "Landscape::ForceArea(): Polygon areas doesn't"" sum up to map area!", "" );
2085  exit( 1 );
2086  }
2087 }

References g_msg, MapErrorMsg::Warn(), and WARN_BUG.

◆ GetActualGooseGrazingForage() [1/2]

double Landscape::GetActualGooseGrazingForage ( int  a_polygon,
GooseSpecies  a_goose 
)
inline

Returns the leaf forage resource as seen from a goose standpoint at a polygon referenced by x,y location The amount of food avaiable as grazing resource based on the vegetation height is species specific.

Parameters
a_polygon[in] The polygon refence number for the polygon we are interested in (assumed grass or cereals). This needs to be checked before calling
a_goose[in] Is the type of goose calling which is needed to determine how to assess the value of the current forage availability (ie its different for different types of geese)
Returns
KJ/min
608  {
609  return m_elems[m_polymapping[a_polygon]]->GetGooseGrazingForage(a_goose);
610  }

References m_elems, and m_polymapping.

◆ GetActualGooseGrazingForage() [2/2]

double Landscape::GetActualGooseGrazingForage ( int  a_x,
int  a_y,
GooseSpecies  a_goose 
)
inline

Returns the leaf forage resource as seen from a goose standpoint at a polygon referenced by x,y location.

Parameters
a_x[in] The x-coordinate in a polygon we are interested in (assumed grass or cereals). This needs to be checked before calling
a_y[in] The x-coordinate in a polygon we are interested in (assumed grass or cereals). This needs to be checked before calling
a_goose[in] Is the type of goose calling which is needed to determine how to assess the value of the current forage availability (ie its different for different types of geese)
Returns
KJ/min
597  {
598  return m_elems[m_land->Get(a_x, a_y)]->GetGooseGrazingForage(a_goose);
599  }

References RasterMap::Get(), m_elems, and m_land.

Referenced by Goose_Base::EvaluateForageToHopLoc(), Goose_Population_Manager::NewForageLocation(), Goose_Base::st_ChooseForageLocation(), and Goose_Base::st_Forage().

◆ GetGooseFields()

GooseFieldList * Landscape::GetGooseFields ( double  a_minopenness)

Gets the list of suitable goose foraging fields today.

Here we need to go through all possible goose feeding locations to find out if they have any forage in them, and then create a list of those to return.
To make this efficient we need to have a list of fields.

First must calculate centroid. Runs through the list of elements and any that have an openness score bigger than our target are saved.

686 {
693  GooseFieldList* alist = new GooseFieldList;
697  GooseFieldListItem gfli;
698  for (unsigned int i = 0; i < m_elems.size(); i++)
699  {
700  if (m_elems[i]->GetOpenness() > a_minopenness)
701  {
702  for (int g = gs_Pinkfoot; g < gs_foobar; g++)
703  {
704  gfli.grass[g] = m_elems[i]->GetGooseGrazingForage((GooseSpecies)g);
705  gfli.geesesp[g] = m_elems[i]->GetGooseSpNosToday((GooseSpecies)g);
706  gfli.geesespTimed[g] = m_elems[i]->GetGooseSpNosTodayTimed((GooseSpecies)g);
707  gfli.roostdists[g] = m_elems[i]->GetGooseRoostDist((GooseSpecies)g);
708  }
709  gfli.grain = m_elems[i]->GetBirdSeed();
710  gfli.maize = m_elems[ i ]->GetBirdMaize();
711  gfli.openness = m_elems[ i ]->GetOpenness();
712  int pref = m_elems[ i ]->GetPoly();
713  gfli.polyref = pref;
714  gfli.geese = m_elems[i]->GetGooseNosToday();
715  gfli.geeseTimed = m_elems[i]->GetGooseNosTodayTimed();
716  gfli.vegtype = m_elems[i]->GetVegType();
717  gfli.vegtypechr = VegtypeToString(m_elems[i]->GetVegType());
718  gfli.vegheight = m_elems[i]->GetVegHeight();
719  gfli.digestability = m_elems[i]->GetDigestability();
720  gfli.vegphase = m_elems[i]->GetVegPhase();
721  gfli.previouscrop = VegtypeToString( m_elems[ i ]->GetPreviousCrop( m_elems[ i ]->GetRotIndex() ) );
722  gfli.lastsownveg = VegtypeToString( m_elems[ i ]->GetLastSownVeg() );
723  alist->push_back(gfli);
724  }
725  }
726  return alist;
727 }
std::vector< GooseFieldListItem > GooseFieldList
A list of GooseFieldListItem s.
Definition: landscape.h:103
A list item entry of field polygon reference numbers with associated openness and goose food scores.
Definition: landscape.h:81
double grass[gs_foobar]
Definition: landscape.h:91
TTypesOfVegetation vegtype
Definition: landscape.h:92
int geese
Definition: landscape.h:83
double grain
Definition: landscape.h:89
std::string vegtypechr
Definition: landscape.h:93
std::string lastsownveg
Definition: landscape.h:98
int polyref
Definition: landscape.h:82
double digestability
Definition: landscape.h:95
double openness
Definition: landscape.h:88
double maize
Definition: landscape.h:90
int geesespTimed[gs_foobar]
Definition: landscape.h:86
std::string previouscrop
Definition: landscape.h:97
int geeseTimed
Definition: landscape.h:85
int roostdists[gs_foobar]
Definition: landscape.h:87
double vegheight
Definition: landscape.h:94
int vegphase
Definition: landscape.h:96
int geesesp[gs_foobar]
Definition: landscape.h:84

References GooseFieldListItem::digestability, GooseFieldListItem::geese, GooseFieldListItem::geesesp, GooseFieldListItem::geesespTimed, GooseFieldListItem::geeseTimed, GooseFieldListItem::grain, GooseFieldListItem::grass, GooseFieldListItem::lastsownveg, GooseFieldListItem::maize, GooseFieldListItem::openness, GooseFieldListItem::polyref, GooseFieldListItem::previouscrop, GooseFieldListItem::roostdists, GooseFieldListItem::vegheight, GooseFieldListItem::vegphase, GooseFieldListItem::vegtype, and GooseFieldListItem::vegtypechr.

Referenced by Goose_Population_Manager::GooseFieldForageInfoOutput().

◆ GetGooseNumbers() [1/2]

int Landscape::GetGooseNumbers ( int  a_poly)

This returns the number of geese on the polygon the day before.

3383  {
3384  return m_elems[m_polymapping[a_polyref]]->GetGooseNos();
3385  }

References m_polymapping.

◆ GetGooseNumbers() [2/2]

int Landscape::GetGooseNumbers ( int  a_x,
int  a_y 
)

This returns the number of geese on the polygon specifed by a_x, a_y the day before.

This returns the number of geese on the polygon the day before.

3398  {
3399  return m_elems[m_land->Get(a_x, a_y)]->GetGooseNos();
3400  }

◆ GetHareFoodQuality()

double Landscape::GetHareFoodQuality ( int  a_polygon)
Todo:
Decide where to classify new LE types for hare 1
3404 {
3405  double digest;
3406  TTypesOfLandscapeElement habitat = SupplyElementType(a_polygon);
3407  switch (habitat) {
3408  // Impossible stuff
3409  case tole_Building:
3410  case tole_Pond:
3411  case tole_Freshwater:
3412  case tole_River:
3413  case tole_Saltwater:
3414  case tole_Coast:
3415  case tole_BareRock:
3416  case tole_ConiferousForest:
3417  case tole_DeciduousForest:
3418  case tole_MixedForest:
3419  case tole_SmallRoad:
3420  case tole_LargeRoad:
3421  case tole_ActivePit:
3422  case tole_UrbanNoVeg:
3423  case tole_UrbanPark:
3424  case tole_SandDune:
3425  case tole_Copse:
3426  case tole_Stream:
3427  case tole_MetalledPath:
3428  case tole_Carpark:
3429  case tole_FishFarm:
3430  case tole_Fence:
3431  // EnergyBalance(activity_Foraging, 100); // This is a bug - it penalises for foraging in impossible areas - not intended but not found until after parameter fitting! Removed 28/07/2014
3432  return 0.0;
3433 
3434  // Questionable stuff
3435  case tole_RiversidePlants:
3436  case tole_RiversideTrees:
3437  case tole_Garden:
3438  case tole_Track:
3439  case tole_StoneWall:
3440  case tole_Hedges:
3441  case tole_Marsh:
3442  case tole_PitDisused:
3443  case tole_RoadsideVerge:
3444  case tole_Railway:
3445  case tole_Scrub:
3446  case tole_AmenityGrass:
3447  case tole_Parkland:
3449  case tole_Churchyard:
3450  case tole_HeritageSite:
3451  return 0.25; // was 0.25 being half of access to low digestability stuff
3452  // case tole_MownGrass:
3453  // digest = 0.8; // Added 28/07/2014 this is a way to compensate for the lack of choice when foraging, i.e. the whole area is assumed to be foraged equally.
3455  case tole_Wasteland:
3456  case tole_IndividualTree:
3457  case tole_WoodyEnergyCrop:
3458  case tole_PlantNursery:
3459  case tole_Pylon:
3460  case tole_WindTurbine:
3461  case tole_WoodlandMargin:
3462  case tole_Vildtager:
3463  default:
3464  digest = SupplyVegDigestability(a_polygon);
3465  }
3466 #ifdef __Perfectfood
3467  return 0.8;
3468 #else
3469 #ifdef __YEARLYVARIABLEFOODQUALITY
3470  digest *= m_OurPopulationManager->m_GoodYearBadYear;
3471 #endif
3472  double veg_height;
3473  double access = 1.0;
3474  // double grazedreduction[4] = { 1.0, 0.75, 0.5, 0.25 };
3475  double grazedreduction[4] = { 1.0, 0.8, 0.2, 0.05 };
3476  veg_height = SupplyVegHeight(a_polygon);
3477  double weeds = SupplyWeedBiomass(a_polygon);
3478  if ((veg_height <= 0) && (weeds < 0.1)) return 0.25; // Always something to eat, but not much.
3479 #ifdef __Hare1950s
3480  bool veg_patchy = true;
3481 #else // If it is not the special case of the 1950s
3482  //
3483  bool veg_patchy = SupplyVegPatchy(a_polygon);
3484 #endif
3485  if (veg_patchy)
3486  {
3487  // Patchy vegetation - normally full access
3488  if (veg_height>50)
3489  {
3490  // no food at only at very very tall
3491  access -= ((veg_height - 50)* g_VegHeightForageReduction);
3492  if (access<0) access = 0;
3493  }
3494  }
3495  else
3496  {
3497  if (veg_height>g_FarmIntensivenessH)
3498  {
3499  access -= ((veg_height - g_FarmIntensivenessH)* /* g_FarmIntensiveness * */ g_VegHeightForageReduction);
3500  if (access<0) access = 0;
3501  }
3502  }
3503  return access * digest * grazedreduction[SupplyGrazingPressure(a_polygon)];
3504 #endif
3505 }
double g_FarmIntensivenessH
Definition: Hare_all.cpp:284
double g_VegHeightForageReduction
Used to scale access to crops for modern day farm intensiveness.
Definition: Hare_all.cpp:282
double SupplyWeedBiomass(int a_polyref)
Definition: landscape.h:964
int SupplyGrazingPressure(int a_polyref)
Definition: landscape.h:1227
double SupplyVegDigestability(int a_polyref)
Definition: landscape.h:919
bool SupplyVegPatchy(int a_polyref)
Definition: landscape.h:986

References g_FarmIntensivenessH, g_VegHeightForageReduction, tole_ActivePit, tole_AmenityGrass, tole_BareRock, tole_Building, tole_BuiltUpWithParkland, tole_Carpark, tole_Churchyard, tole_Coast, tole_ConiferousForest, tole_Copse, tole_DeciduousForest, tole_Fence, tole_FishFarm, tole_Freshwater, tole_Garden, tole_Hedges, tole_HeritageSite, tole_IndividualTree, tole_LargeRoad, tole_Marsh, tole_MetalledPath, tole_MixedForest, tole_Parkland, tole_PitDisused, tole_PlantNursery, tole_Pond, tole_Pylon, tole_Railway, tole_River, tole_RiversidePlants, tole_RiversideTrees, tole_RoadsideVerge, tole_Saltwater, tole_SandDune, tole_Scrub, tole_SmallRoad, tole_StoneWall, tole_Stream, tole_Track, tole_UrbanNoVeg, tole_UrbanPark, tole_Vildtager, tole_Wasteland, tole_WindTurbine, tole_WoodlandMargin, and tole_WoodyEnergyCrop.

Referenced by THare::ForageSquare(), THare::ForageSquareP(), and Hare_Juvenile::st_Dispersal().

◆ GetPolymapping()

int Landscape::GetPolymapping ( int  a_index)
inline
183 { return m_polymapping[a_index]; }

References m_polymapping.

◆ GetQuarryNumbers()

int Landscape::GetQuarryNumbers ( int  a_poly)

This returns the number of geese which are legal quarry on the polygon the day before.

This returns the number of geese on the polygon the day before.

3390  {
3391  return m_elems[m_polymapping[a_polyref]]->GetQuarryNos();
3392  }

References m_polymapping.

Referenced by GooseHunter::CheckForGame().

◆ GetVegArea()

double Landscape::GetVegArea ( int  v)
inline

◆ GISASCII_Output()

void Landscape::GISASCII_Output ( string  outpfile,
int  UTMX,
int  UTMY 
)
protected

Write ASCII file of the ALMaSS map.

Here we write a ASCII file of the current map. Useful when visualizing output from simulations. The function will output the entity that is defined in the config: l_map_ascii_map_entity. The default is polyref number (l_map_ascii_map_entity = 1).

Parameters
[in]outpfileName of the output file
[in]UTMXUtm x-coordinate of the lower lefthand corner of the map
[in]UTMYUtm y-coordinate of the lower lefthand corner of the map
3507  {
3515  FILE* OFILE;
3516  OFILE = fopen( outpfile.c_str(), "w" );
3517  if (!OFILE) {
3518  g_msg->Warn( WARN_FILE, "Landscape::GISASCII_Output() "
3519  "Unable to open file for writing:",
3520  outpfile );
3521  exit( 1 );
3522  }
3523  char c = '\n';
3524  fprintf(OFILE, "ncols %d\n", m_width);
3525  fprintf(OFILE, "nrows %d\n", m_height);
3526  fprintf(OFILE, "xllcorner %d\n", UTMX );
3527  fprintf(OFILE, "yllcorner %d\n", UTMY );
3528  fprintf(OFILE, "cellsize %d\n", 1 );
3529  fprintf(OFILE, "NODATA_value %d\n", -9999 );
3530  // The polyref loop
3531  if (l_map_ascii_map_entity.value() == 1) {
3532  for (int y = 0; y < m_height; y++) {
3533  for (int x = 0; x < m_width; x++) {
3534  fprintf(OFILE, "%d\t", SupplyPolyRef(x, y));
3535  }
3536  fprintf(OFILE, "%c", c );
3537  }
3538  }
3539  // The element type loop
3540  if (l_map_ascii_map_entity.value() == 2) {
3541  for (int y = 0; y < m_height; y++) {
3542  for (int x = 0; x < m_width; x++) {
3543  fprintf(OFILE, "%d\t", SupplyElementType( x, y ));
3544  }
3545  fprintf( OFILE, "%c", c );
3546  }
3547  }
3548  fclose( OFILE );
3549 }
static CfgInt l_map_ascii_map_entity("MAP_ASCII_MAP_ENTITY", CFG_CUSTOM, 1)
If we write an ASCII file what should be the mapped entity? 1 = polyref, 2 = elementype.

References g_msg, l_map_ascii_map_entity, CfgInt::value(), MapErrorMsg::Warn(), and WARN_FILE.

◆ GrazeVegetation()

void Landscape::GrazeVegetation ( int  a_poly,
double  a_forage 
)
inline

Removes grazing forage from a poly per m2.

670  {
671  m_elems[ m_polymapping[ a_poly ] ]->GrazeVegetation( a_forage, true );
672  }

References m_elems, and m_polymapping.

◆ GrazeVegetationTotal()

void Landscape::GrazeVegetationTotal ( int  a_poly,
double  a_forage 
)
inline

Removes grazing forage from a poly and divides this out per m2.

676  {
677  m_elems[ m_polymapping[ a_poly ] ]->GrazeVegetationTotal( a_forage );
678  }

References m_elems, and m_polymapping.

Referenced by Goose_Population_Manager::DoLast().

◆ hb_Add()

void Landscape::hb_Add ( void  )
protected
57 {
58  // Make a local copy of the actual map parameters for speed
59  // purposes. We are going to use these *a lot*.
60  hb_map = m_land->GetMagicP( 0, 0 );
64 
65  //#ifdef HB_TESTING
66  //m_elems[m_polymapping
67  //[hb_map[750 + 600*hb_width]]]->SetElementType( tole_Hedges );
68  //#endif
69 
70  // Generate a list of polygon numbers + HB_MAGIC for all hedge elements
71  // in our current map.
72  hb_FindHedges();
73 
74  // As one lemming at the cliff edge said to the other: "Let's Go!"
75 
76  // For every hedge polygon:
77  printf("Hedges: %d\n", int(hb_hedges.size()));
78  fflush(stdout);
79 
80  double l_inc = 50.0/((double)hb_hedges.size());
81  double l_count = 0.001;
82 
83  for ( unsigned int i=0; i<hb_hedges.size(); i++ ) {
84  l_count += l_inc;
85  if ( l_count > 1.0 ) {
86  l_count = 0.001;
87  printf(".");
88  fflush(stdout);
89  }
90  // Find the enclosing bounding box for our current polygon.
91  if ( ! hb_FindBoundingBox( hb_hedges[i] )) {
92  // Might want to raise a runtime error upon ending here.
93  // The test for hb_FindBoundingBox() fails if we have a polygon
94  // without any pixels in the main map!
95  continue;
96  }
97 
98  // Move all polygon numbers in our bounding box up! by HB_MAGIC
99  // to make room for our 'paint' values in the space below.
101 
103 
104  hb_PaintBorder( 0 );
105 
106  int l_color = 0;
107  while ( hb_PaintWhoHasNeighbourColor( l_color,
108  l_color + 1 )) {
109  l_color++;
110  }
111 
112  double l_percent = (double)hb_core_pixels/
113  ((double)hb_core_pixels+(double)hb_border_pixels);
114 
115  if ( l_percent > l_map_art_hb_core_thres.value()) {
116  // We ought to have at least *some* visible core area
117  // within the polygon, so do a simple scan.
118 
119  // l_color now happens to contain the maximum contour/color value
120  // within our current polygon.
121  int l_min = (int)((double)l_color * l_map_art_hb_width.value());
122  while ( l_color > l_min ) {
123  hb_MarkTopFromLocalMax( l_color );
125  l_color--;
126  }
127  } else {
128  // Very thin hedge (1->2 meters),
129  // use special border case scan when adding hedge banks.
131  }
132 
134 
135  // All the previous steps were just preparations.
136  // Now do the serious stuff.
138 
139 #ifdef HB_TESTING
140  // Sanity check.
141  for ( int j=0; j<hb_size; j++ ) {
142  if ( m_polymapping[ hb_map[ j ] - HB_MAGIC ] == -1 ) {
143  printf("Oh dear!\n");
144  exit(1);
145  }
146  }
147 
148  char ffname[24];
149  sprintf( ffname, "test%02d.ppm", i);
150 #endif
151 
152  // Restore order to the map before continuing.
154 
155 #ifdef HB_TESTING
156  hb_dump_map( 0, hb_width, 0, hb_height, ffname, false );
157 #endif
158  }
159 
160  printf("\n");
161 #ifdef HB_TESTING
162  // Quick reminder.
163  for ( unsigned int i=0; i<m_elems.size(); i++ ) {
164  if ( m_elems[i]->GetArea() < 0.9 &&
165  m_elems[i]->GetElementType() != tole_FieldBoundary ) {
166  // Note: Field boundaries have not been scanned yet at this point,
167  // so they will have a zero area right here and now.
168  printf("Warning: Polygon %6d of type %s came up with area %3.2f!\n",
169  m_elems[i]->GetPoly(),
170  PolytypeToString( m_elems[i]->GetElementType() ),
171  m_elems[i]->GetArea() );
172  }
173  }
174  exit(0);
175 #endif
176 }
int hb_core_pixels
Definition: landscape.h:275
void hb_RestoreHedgeCore(int a_orig_poly_number)
Definition: hedgebanks.cpp:311
void hb_PaintBorder(int a_color)
Definition: hedgebanks.cpp:429
int hb_border_pixels
Definition: landscape.h:276
int hb_width
Definition: landscape.h:269
int hb_size
Definition: landscape.h:271
void hb_AddNewHedgebanks(int a_orig_poly_num)
Definition: hedgebanks.cpp:198
int * hb_map
Definition: landscape.h:268
vector< int > hb_hedges
Definition: landscape.h:263
std::string PolytypeToString(TTypesOfLandscapeElement a_le_type)
Definition: Landscape.cpp:4087
void hb_FindHedges(void)
Definition: hedgebanks.cpp:276
void hb_DownPolyNumbers(void)
Definition: hedgebanks.cpp:715
void hb_ClearPolygon(int a_poly_num)
Definition: hedgebanks.cpp:413
void hb_MarkTopFromLocalMax(int a_color)
Definition: hedgebanks.cpp:679
void hb_ResetColorBits(void)
Definition: hedgebanks.cpp:298
int hb_height
Definition: landscape.h:270
void hb_MarkTheBresenhamWay(void)
Definition: hedgebanks.cpp:629
bool hb_PaintWhoHasNeighbourColor(int a_neighbour_color, int a_new_color)
Definition: hedgebanks.cpp:526
void hb_UpPolyNumbers(void)
Definition: hedgebanks.cpp:289
bool hb_FindBoundingBox(int a_poly_num)
Definition: hedgebanks.cpp:243
static CfgFloat l_map_art_hb_width("MAP_ART_HB_WIDTH", CFG_CUSTOM, 0.3)
static CfgFloat l_map_art_hb_core_thres("MAP_ART_HB_STRIPE_THRES", CFG_CUSTOM, 0.4)
#define HB_MAGIC
Definition: hedgebanks.cpp:38

References RasterMap::GetMagicP(), hb_AddNewHedgebanks(), hb_border_pixels, hb_ClearPolygon(), hb_core_pixels, hb_DownPolyNumbers(), hb_FindBoundingBox(), hb_FindHedges(), hb_hedges, hb_height, HB_MAGIC, hb_map, hb_MarkTheBresenhamWay(), hb_MarkTopFromLocalMax(), hb_PaintBorder(), hb_PaintWhoHasNeighbourColor(), hb_ResetColorBits(), hb_RestoreHedgeCore(), hb_size, hb_UpPolyNumbers(), hb_width, l_map_art_hb_core_thres, l_map_art_hb_width, m_elems, m_land, m_polymapping, RasterMap::MapHeight(), RasterMap::MapWidth(), PolytypeToString(), tole_FieldBoundary, and CfgFloat::value().

◆ hb_AddNewHedgebanks()

void Landscape::hb_AddNewHedgebanks ( int  a_orig_poly_num)
protected
199 {
201 
202  for ( int l_y=hb_min_y; l_y<=hb_max_y; l_y++ ) {
203  for ( int l_x=hb_min_x; l_x<=hb_max_x; l_x++ ) {
204  int i = l_y*hb_width + l_x;
205  int l_val = hb_map[ i ];
206  if ( l_val >= 0 && l_val < HB_MAGIC ) {
207  hb_map[ i ] = hb_StripingDist() + HB_MAGIC;
208  /*
209  m_elems[m_polymapping[hb_map[ i ]-HB_MAGIC]]->AddArea( 1.0 );
210  m_elems[m_polymapping[hb_map[ i ]-HB_MAGIC]]->m_squares_in_map++;
211  m_elems[m_polymapping[a_orig_poly_num]]->AddArea( -1.0 );
212  if ( m_elems[m_polymapping[a_orig_poly_num]]->GetArea() < 0.0 ) {
213  printf("%d %d !!!\n", l_x, l_y );
214  exit(1);
215  }
216  */
217  //m_elems[m_polymapping[a_orig_poly_num]]->m_squares_in_map--;
218  }
219  }
220  }
221 }
int hb_min_y
Definition: landscape.h:273
void hb_GenerateHBPolys(void)
Definition: hedgebanks.cpp:180
int hb_min_x
Definition: landscape.h:272
int hb_StripingDist(void)
Definition: hedgebanks.cpp:225
int hb_max_x
Definition: landscape.h:272
int hb_max_y
Definition: landscape.h:273

References hb_GenerateHBPolys(), HB_MAGIC, hb_map, hb_max_x, hb_max_y, hb_min_x, hb_min_y, hb_StripingDist(), and hb_width.

Referenced by hb_Add().

◆ hb_Cleanup()

void Landscape::hb_Cleanup ( void  )
protected

◆ hb_ClearPolygon()

void Landscape::hb_ClearPolygon ( int  a_poly_num)
protected
414 {
415  // 'Paint' every pixel which belongs to the current polygon with the
416  // value HB_MAGIC_COLOR.
417  for ( int l_y=hb_min_y; l_y<=hb_max_y; l_y++ ) {
418  for ( int l_x=hb_min_x; l_x<=hb_max_x; l_x++ ) {
419  int l_coord = l_y*hb_width + l_x;
420  if ( hb_map[ l_coord ] == a_poly_num ) {
421  hb_map[ l_coord ] = HB_MAGIC_COLOR;
422  }
423  }
424  }
425 }
#define HB_MAGIC_COLOR
Definition: hedgebanks.cpp:39

References HB_MAGIC_COLOR, hb_map, hb_max_x, hb_max_y, hb_min_x, hb_min_y, and hb_width.

Referenced by hb_Add().

◆ hb_DownPolyNumbers()

void Landscape::hb_DownPolyNumbers ( void  )
protected
716 {
717  for ( int i=0; i<hb_size; i++ ) {
718  if ( hb_map[ i ] >= HB_MAGIC ) {
719  hb_map[ i ] -= HB_MAGIC;
720  }
721  }
722 }

References HB_MAGIC, hb_map, and hb_size.

Referenced by hb_Add().

◆ hb_FindBoundingBox()

bool Landscape::hb_FindBoundingBox ( int  a_poly_num)
protected
244 {
245  hb_min_x = hb_width + 1;
246  hb_max_x = -1;
247 
248  hb_min_y = hb_height + 1;
249  hb_max_y = -1;
250 
251  bool l_found = false;
252 
253  // Search for every pixel which belongs to the current polygon, and
254  // min and max values for x and y. Values are inclusive.
255  for ( int l_y=0; l_y<hb_height; l_y++ ) {
256  for ( int l_x=0; l_x<hb_width; l_x++ ) {
257  if ( hb_map[ l_y*hb_width + l_x ] == a_poly_num ) {
258  l_found = true;
259  if ( l_x < hb_min_x)
260  hb_min_x = l_x;
261  else if ( l_x > hb_max_x)
262  hb_max_x = l_x;
263  if ( l_y < hb_min_y)
264  hb_min_y = l_y;
265  else if ( l_y > hb_max_y)
266  hb_max_y = l_y;
267  }
268  }
269  }
270 
271  return l_found;
272 }

References hb_height, hb_map, hb_max_x, hb_max_y, hb_min_x, hb_min_y, and hb_width.

Referenced by hb_Add().

◆ hb_FindHedges()

void Landscape::hb_FindHedges ( void  )
protected
277 {
278  for ( unsigned int i=0; i<m_elems.size(); i++ ) {
279  if ( tole_Hedges == m_elems[i]->GetElementType() ) {
280  hb_hedges.resize( hb_hedges.size() + 1 );
281  hb_hedges[ hb_hedges.size() - 1 ] =
282  m_elems[i]->GetPoly();
283  }
284  }
285 }

References hb_hedges, m_elems, and tole_Hedges.

Referenced by hb_Add().

◆ hb_GenerateHBPolys()

void Landscape::hb_GenerateHBPolys ( void  )
protected
181 {
182  hb_new_hbs.resize( l_map_art_hb_nums.value() );
183 
184  for ( int i =0; i<l_map_art_hb_nums.value(); i++ ) {
186  hb_new_hbs[ i ]->SetArea( 0.0 );
187  hb_new_hbs[ i ]->SetSubType( i );
188  m_elems.resize( m_elems.size() + 1 );
189  m_elems[ m_elems.size() - 1 ] = hb_new_hbs[ i ];
191  (int) m_elems.size() - 1;
192  hb_new_hbs[ i ]->SetPoly( hb_first_free_poly_num++ );
193  }
194 }
vector< LE * > hb_new_hbs
Definition: landscape.h:264
static CfgInt l_map_art_hb_nums("MAP_ART_HB_NUMS", CFG_CUSTOM, 3)

References hb_first_free_poly_num, hb_new_hbs, l_map_art_hb_nums, m_elems, m_polymapping, NewElement(), tole_HedgeBank, and CfgInt::value().

Referenced by hb_AddNewHedgebanks().

◆ hb_HasNeighbourColor()

bool Landscape::hb_HasNeighbourColor ( int  a_x,
int  a_y,
int  a_neighbour_color 
)
inlineprotected
454 {
455  bool l_neighbour_has_color = false;
456  bool loop=false;
457 
458  do {
459  a_x -= 1;
460  a_y -= 1;
461  if ( a_x >= 0 && a_y >= 0 &&
462  hb_map[ a_x + a_y*hb_width ] == a_neighbour_color ) {
463  l_neighbour_has_color = true;
464  break;
465  }
466 
467  a_x++;
468  if ( hb_map[ a_x + a_y*hb_width ] == a_neighbour_color ) {
469  l_neighbour_has_color = true;
470  break;
471  }
472 
473  a_x++;
474  if ( a_x < hb_width &&
475  hb_map[ a_x + a_y*hb_width ] == a_neighbour_color ) {
476  l_neighbour_has_color = true;
477  break;
478  }
479 
480  a_x -= 2;
481  a_y += 1;
482  if ( a_x >= 0 &&
483  hb_map[ a_x + a_y*hb_width ] == a_neighbour_color ) {
484  l_neighbour_has_color = true;
485  break;
486  }
487 
488  a_x += 2;
489  if ( a_x < hb_width &&
490  hb_map[ a_x + a_y*hb_width ] == a_neighbour_color ) {
491  l_neighbour_has_color = true;
492  break;
493  }
494 
495  a_x -= 2;
496  a_y += 1;
497 
498  if ( a_y >= hb_height )
499  break;
500 
501  if ( a_x >= 0 &&
502  hb_map[ a_x + a_y*hb_width ] == a_neighbour_color ) {
503  l_neighbour_has_color = true;
504  break;
505  }
506 
507  a_x++;
508  if ( hb_map[ a_x + a_y*hb_width ] == a_neighbour_color ) {
509  l_neighbour_has_color = true;
510  break;
511  }
512 
513  a_x++;
514  if ( a_x < hb_width &&
515  hb_map[ a_x + a_y*hb_width ] == a_neighbour_color ) {
516  l_neighbour_has_color = true;
517  break;
518  }
519  } while ( loop ); // was while (false) CJT 16-05-06
520 
521  return l_neighbour_has_color;
522 }

References hb_height, hb_map, and hb_width.

Referenced by hb_PaintWhoHasNeighbourColor().

◆ hb_HasOtherNeighbour()

bool Landscape::hb_HasOtherNeighbour ( int  a_x,
int  a_y 
)
inlineprotected
340 {
341  bool l_has_neighbour = false;
342  bool loop=false;
343 
344  // Who said C++ needs the goto statement? ;-)
345  do {
346  a_x -= 1;
347  a_y -= 1;
348 
349  if ( hb_MapBorder( a_x, a_y ) ||
350  hb_map[ a_x + a_y*hb_width ] >= HB_MAGIC ) {
351  l_has_neighbour = true;
352  break;
353  }
354 
355  a_x++;
356  if ( hb_MapBorder( a_x, a_y ) ||
357  hb_map[ a_x + a_y*hb_width ] >= HB_MAGIC ) {
358  l_has_neighbour = true;
359  break;
360  }
361 
362  a_x++;
363  if ( hb_MapBorder( a_x, a_y ) ||
364  hb_map[ a_x + a_y*hb_width ] >= HB_MAGIC ) {
365  l_has_neighbour = true;
366  break;
367  }
368 
369  a_x -= 2;
370  a_y += 1;
371  if ( hb_MapBorder( a_x, a_y ) ||
372  hb_map[ a_x + a_y*hb_width ] >= HB_MAGIC ) {
373  l_has_neighbour = true;
374  break;
375  }
376 
377  a_x += 2;
378  if ( hb_MapBorder( a_x, a_y ) ||
379  hb_map[ a_x + a_y*hb_width ] >= HB_MAGIC ) {
380  l_has_neighbour = true;
381  break;
382  }
383 
384  a_x -= 2;
385  a_y += 1;
386 
387  if ( hb_MapBorder( a_x, a_y ) ||
388  hb_map[ a_x + a_y*hb_width ] >= HB_MAGIC ) {
389  l_has_neighbour = true;
390  break;
391  }
392 
393  a_x++;
394  if ( hb_MapBorder( a_x, a_y ) ||
395  hb_map[ a_x + a_y*hb_width ] >= HB_MAGIC ) {
396  l_has_neighbour = true;
397  break;
398  }
399 
400  a_x++;
401  if ( hb_MapBorder( a_x, a_y ) ||
402  hb_map[ a_x + a_y*hb_width ] >= HB_MAGIC ) {
403  l_has_neighbour = true;
404  break;
405  }
406  } while ( loop ); // was while (false) CJT 16-05-06
407 
408  return l_has_neighbour;
409 }
bool hb_MapBorder(int a_x, int a_y)
Definition: hedgebanks.cpp:325

References HB_MAGIC, hb_map, hb_MapBorder(), and hb_width.

Referenced by hb_PaintBorder().

◆ hb_MapBorder()

bool Landscape::hb_MapBorder ( int  a_x,
int  a_y 
)
inlineprotected
326 {
327  if ( a_x < 0 ||
328  a_y < 0 ||
329  a_x >= hb_width ||
330  a_y >= hb_height ) {
331  return true;
332  }
333 
334  return false;
335 }

References hb_height, and hb_width.

Referenced by hb_HasOtherNeighbour().

◆ hb_MarkTheBresenhamWay()

void Landscape::hb_MarkTheBresenhamWay ( void  )
protected
630 {
631  double l_hb = l_map_art_hb_width.value()*10000.0;
632  double l_up = 10000.0 - l_hb;
633  bool l_is_hb = true;
634  double l_length = (double)(random( (int)l_hb )) * 0.0001 *
636  double l_hb_remain = 0.0;
637  double l_up_remain = 0.0;
638 
639  for ( int l_y=hb_min_y; l_y<=hb_max_y; l_y++) {
640  // Note: The missing update of l_x below is intentional.
641  for ( int l_x=hb_min_x; l_x<=hb_max_x; ) {
642  int l_coord = l_y*hb_width + l_x;
643  if ( hb_map[ l_coord ] < HB_MAGIC ) {
644  // 'Painting' with a negative value turns a pixel into
645  // hedgebank 'core', ie. hedge!
646 
647  // Paint segment length with appropriate type.
648  if ( l_length >= 1.0 ) {
649  if ( l_is_hb ) {
650  hb_map[ l_coord ] = 0;
651  } else {
652  hb_map[ l_coord ] = -1;
653  }
654  l_length -= 1.0;
655  l_x++;
656  } else {
657  // Change state.
658  if ( l_is_hb ) {
659  l_is_hb = false;
660  l_hb_remain = l_length;
661  l_length = (double)(random( (int)l_up )) * 0.0001 *
662  l_map_art_hb_seg_len.value() + l_up_remain;
663  } else {
664  l_is_hb = true;
665  l_up_remain = l_length;
666  l_length = (double)(random( (int)l_hb )) * 0.0001 *
667  l_map_art_hb_seg_len.value() + l_hb_remain;
668  }
669  }
670  } else {
671  // Pixel not part of the hedge, just update the coordinate.
672  l_x++;
673  }
674  }
675  }
676 }
static CfgFloat l_map_art_hb_seg_len("MAP_ART_HB_SEG_LEN", CFG_CUSTOM, 100.0)

References HB_MAGIC, hb_map, hb_max_x, hb_max_y, hb_min_x, hb_min_y, hb_width, l_map_art_hb_seg_len, l_map_art_hb_width, random(), and CfgFloat::value().

Referenced by hb_Add().

◆ hb_MarkTopFromLocalMax()

void Landscape::hb_MarkTopFromLocalMax ( int  a_color)
protected
680 {
681  // Sweep through the map. If we find a pixel, which has a value
682  // equal to a_color and *not* a negative neighbour, then mark it as
683  // negative with an absolute value equal to the number of steps from
684  // here and out to the center/perimeter polygons border, calculated
685  // as the given percentage.
686 
687  // If one or more negative numbers are found among the neighbours,
688  // some that were not marked during this round, then assign a
689  // negative value equal to the minimum found plus one.
690 
691  for ( int l_y=hb_min_y; l_y<=hb_max_y; l_y++ ) {
692  for ( int l_x=hb_min_x; l_x<=hb_max_x; l_x++ ) {
693  int l_coord = l_y*hb_width + l_x;
694  int l_max;
695  if ( hb_map[ l_coord ] == a_color ) {
696  l_max = hb_MaxUnpaintedNegNeighbour( l_x, l_y );
697  if ( l_max < 0 ) {
698  if ( ++l_max < 0 ) {
699  hb_map[ l_coord ] = l_max;
700  } else {
701  // l_max was precisely -1
702  hb_map[ l_coord ] = -1;
703  }
704  } else {
705  // We are a local maxima.
706  hb_map[ l_coord ] = -a_color;
707  }
708  hb_map[ l_coord ] ^= HB_MAGIC_PAINTER_BIT;
709  }
710  }
711  }
712 }
int hb_MaxUnpaintedNegNeighbour(int a_x, int a_y)
Definition: hedgebanks.cpp:548
#define HB_MAGIC_PAINTER_BIT
Definition: hedgebanks.cpp:40

References HB_MAGIC_PAINTER_BIT, hb_map, hb_max_x, hb_max_y, hb_MaxUnpaintedNegNeighbour(), hb_min_x, hb_min_y, and hb_width.

Referenced by hb_Add().

◆ hb_MaxUnpaintedNegNeighbour()

int Landscape::hb_MaxUnpaintedNegNeighbour ( int  a_x,
int  a_y 
)
inlineprotected
550 {
551  int l_max_neg = 0;
552  int l_val;
553  bool loop=false; // This is just to avoid the warning about constant expression if we use: do {...} while (false)
554 
555  do {
556  a_x -= 1;
557  a_y -= 1;
558  if ( a_x >= 0 && a_y >= 0 ) {
559  l_val = hb_map[ a_x + a_y*hb_width ];
560  if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
561  l_max_neg = l_val;
562  }
563  }
564 
565  a_x++;
566  l_val = hb_map[ a_x + a_y*hb_width ];
567  if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
568  l_max_neg = l_val;
569  }
570 
571  a_x++;
572  if ( a_x < hb_width ) {
573  l_val = hb_map[ a_x + a_y*hb_width ];
574  if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
575  l_max_neg = l_val;
576  }
577  }
578 
579  a_x -= 2;
580  a_y += 1;
581  if ( a_x >= 0 ) {
582  l_val = hb_map[ a_x + a_y*hb_width ];
583  if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
584  l_max_neg = l_val;
585  }
586  }
587 
588  a_x += 2;
589  if ( a_x < hb_width ) {
590  l_val = hb_map[ a_x + a_y*hb_width ];
591  if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
592  l_max_neg = l_val;
593  }
594  }
595 
596  a_x -= 2;
597  a_y += 1;
598 
599  if ( a_y >= hb_height )
600  break;
601 
602  if ( a_x >= 0 ) {
603  l_val = hb_map[ a_x + a_y*hb_width ];
604  if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
605  l_max_neg = l_val;
606  }
607  }
608 
609  a_x++;
610  l_val = hb_map[ a_x + a_y*hb_width ];
611  if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
612  l_max_neg = l_val;
613  }
614 
615  a_x++;
616  if ( a_x < hb_width ) {
617  l_val = hb_map[ a_x + a_y*hb_width ];
618  if ( l_val < l_max_neg && (l_val & HB_MAGIC_PAINTER_BIT)) {
619  l_max_neg = l_val;
620  }
621  }
622  } while ( loop );
623 
624  return l_max_neg;
625 }

References hb_height, HB_MAGIC_PAINTER_BIT, hb_map, and hb_width.

Referenced by hb_MarkTopFromLocalMax().

◆ hb_PaintBorder()

void Landscape::hb_PaintBorder ( int  a_color)
protected
430 {
431  hb_border_pixels = 0;
432  hb_core_pixels = 0;
433  // Paint every pixel which belongs to the current polygon, and which
434  // does have a neighbour *not* equal to HB_MAGIC_COLOR (our marker value).
435  for ( int l_y=hb_min_y; l_y<=hb_max_y; l_y++ ) {
436  for ( int l_x=hb_min_x; l_x<=hb_max_x; l_x++ ) {
437  int l_coord = l_y*hb_width + l_x;
438  if ( hb_map[ l_coord ] == HB_MAGIC_COLOR ) {
439  if ( hb_HasOtherNeighbour( l_x, l_y )) {
440  hb_map[ l_coord ] = a_color;
442  } else {
443  hb_core_pixels++;
444  }
445  }
446  }
447  }
448 }
bool hb_HasOtherNeighbour(int a_x, int a_y)
Definition: hedgebanks.cpp:339

References hb_border_pixels, hb_core_pixels, hb_HasOtherNeighbour(), HB_MAGIC_COLOR, hb_map, hb_max_x, hb_max_y, hb_min_x, hb_min_y, and hb_width.

Referenced by hb_Add().

◆ hb_PaintWhoHasNeighbourColor()

bool Landscape::hb_PaintWhoHasNeighbourColor ( int  a_neighbour_color,
int  a_new_color 
)
protected
528 {
529  // Paint every pixel which belongs to the current polygon, and which
530  // has a neighbour with a color equal to a_neighbour_color.
531 
532  bool l_at_least_one = false;
533  for ( int l_y=hb_min_y; l_y<=hb_max_y; l_y++ ) {
534  for ( int l_x=hb_min_x; l_x<=hb_max_x; l_x++ ) {
535  if ( hb_map[l_y*hb_width + l_x] == HB_MAGIC_COLOR &&
536  hb_HasNeighbourColor( l_x, l_y, a_neighbour_color )) {
537  hb_map[l_y*hb_width + l_x] = a_new_color;
538  l_at_least_one = true;
539  }
540  }
541  }
542 
543  return l_at_least_one;
544 }
bool hb_HasNeighbourColor(int a_x, int a_y, int a_neighbour_color)
Definition: hedgebanks.cpp:452

References hb_HasNeighbourColor(), HB_MAGIC_COLOR, hb_map, hb_max_x, hb_max_y, hb_min_x, hb_min_y, and hb_width.

Referenced by hb_Add().

◆ hb_ResetColorBits()

void Landscape::hb_ResetColorBits ( void  )
protected
299 {
300  for ( int l_y=hb_min_y; l_y<=hb_max_y; l_y++ ) {
301  for ( int l_x=hb_min_x; l_x<=hb_max_x; l_x++ ) {
302  int l_coord = l_y*hb_width + l_x;
303  if ( hb_map[l_coord] < 0 )
304  hb_map[l_coord] |= HB_MAGIC_PAINTER_BIT;
305  }
306  }
307 }

References HB_MAGIC_PAINTER_BIT, hb_map, hb_max_x, hb_max_y, hb_min_x, hb_min_y, and hb_width.

Referenced by hb_Add().

◆ hb_RestoreHedgeCore()

void Landscape::hb_RestoreHedgeCore ( int  a_orig_poly_number)
protected
312 {
313  for ( int l_y=hb_min_y; l_y<=hb_max_y; l_y++ ) {
314  for ( int l_x=hb_min_x; l_x<=hb_max_x; l_x++ ) {
315  int l_coord = l_y*hb_width + l_x;
316  if ( hb_map[l_coord] < 0 ) {
317  hb_map[l_coord] = a_orig_poly_number;
318  }
319  }
320  }
321 }

References hb_map, hb_max_x, hb_max_y, hb_min_x, hb_min_y, and hb_width.

Referenced by hb_Add().

◆ hb_StripingDist()

int Landscape::hb_StripingDist ( void  )
protected
226 {
227  // Striping distribution function for the new hedgebanks.
228  static LE* l_curr_ele = NULL;
229 
230  if ( !l_curr_ele ) {
231  l_curr_ele = hb_new_hbs[ random( l_map_art_hb_nums.value()) ];
232  return l_curr_ele->GetPoly();
233  }
234 
235  if ( random(100) < l_map_art_hb_tran_prob.value() )
236  l_curr_ele = hb_new_hbs[ random( l_map_art_hb_nums.value()) ];
237 
238  return l_curr_ele->GetPoly();
239 }
static CfgInt l_map_art_hb_tran_prob("MAP_ART_HB_TRAN_PROB", CFG_CUSTOM, 30)

References LE::GetPoly(), hb_new_hbs, l_map_art_hb_nums, l_map_art_hb_tran_prob, random(), and CfgInt::value().

Referenced